/** * @covers Imagine\Image\Box::getWidth * @covers Imagine\Image\Box::getHeight * * @dataProvider getSizes * * @param integer $width * @param integer $height */ public function testShouldAssignWidthAndHeight($width, $height) { $size = new Box($width, $height); $this->assertEquals($width, $size->getWidth()); $this->assertEquals($height, $size->getHeight()); }
/** * Put Element in Column * * @author WN * @param Box|string $element * @param int $columns * @param int $column * @param int $row * @param bool $center * @return $this */ public function putInColumn($element, $columns, $column, $row, $center = true) { if ($column < 1 || $columns < 1 || $column > $columns) { throw new \InvalidArgumentException('Columns and column must be positive integer'); } if ($element instanceof ContainerInterface) { $width = $element->getWidth(); } elseif (is_string($element)) { $width = strlen($element); } else { throw new \InvalidArgumentException('Unsupported type of element'); } $columnSize = $this->getWidth() / $columns; $offset = floor(($column - 1) * $columnSize + ($center ? floor(($columnSize - $width) / 2) : 0)); $this->put($element, $offset, $row); return $this; }