Ejemplo n.º 1
0
 /**
  * @dataProvider correctDimensionProvider
  */
 public function testCorrectValues($width, $height)
 {
     $dimension = new Dimension($width, $height);
     $this->assertEquals($width, $dimension->getWidth());
     if ($height === null) {
         $this->assertEquals($width, $dimension->getHeight());
     } else {
         $this->assertEquals($height, $dimension->getHeight());
     }
 }
 /**
  * Set size
  *
  * set new width and height for the current dimension using the width and
  * the hight of the passed dimension
  *
  * @param \Jaguar\Dimension $dimension
  *
  * @return \Jaguar\Dimension
  */
 public function setSize(Dimension $dimension)
 {
     return $this->setWidth($dimension->getWidth())->setHeight($dimension->getHeight());
 }
Ejemplo n.º 3
0
 /**
  * Creates a ratio based on Dimension.
  *
  * The strategy parameter forces by default to use standardized ratios. If
  * custom ratio need to be used, disable it.
  *
  * @param Dimension $dimension
  * @param Boolean   $forceStandards Whether to force or not standard ratios
  *
  * @return AspectRatio
  *
  * @throws InvalidArgumentException
  */
 public static function create(Dimension $dimension, $forceStandards = true)
 {
     $incoming = $dimension->getWidth() / $dimension->getHeight();
     if ($forceStandards) {
         return new static(static::nearestStrategy($incoming));
     } else {
         return new static(static::customStrategy($incoming));
     }
 }