mirror of
https://github.com/Intervention/image.git
synced 2025-08-31 01:29:51 +02:00
Add method Rectangle::setSize()
This commit is contained in:
@@ -20,6 +20,11 @@ class Rectangle extends Polygon implements SizeInterface
|
||||
$this->addPoint(new Point($this->pivot->getX(), $this->pivot->getY() - $height));
|
||||
}
|
||||
|
||||
public function setSize(int $width, int $height): self
|
||||
{
|
||||
return $this->setWidth($width)->setHeight($height);
|
||||
}
|
||||
|
||||
public function setWidth(int $width): self
|
||||
{
|
||||
$this[1]->setX($this[0]->getX() + $width);
|
||||
|
@@ -23,6 +23,14 @@ class RectangleTest extends TestCase
|
||||
$this->assertEquals(200, $rectangle->getHeight());
|
||||
}
|
||||
|
||||
public function testSetSize(): void
|
||||
{
|
||||
$rectangle = new Rectangle(300, 200);
|
||||
$rectangle->setSize(12, 34);
|
||||
$this->assertEquals(12, $rectangle->getWidth());
|
||||
$this->assertEquals(34, $rectangle->getHeight());
|
||||
}
|
||||
|
||||
public function testWithWidth(): void
|
||||
{
|
||||
$rectangle = new Rectangle(300, 200);
|
||||
|
Reference in New Issue
Block a user