1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-26 15:24:37 +02:00

Rename method

- SizeInterface::getAspectRatio to SizeInterface::aspectRatio
This commit is contained in:
Oliver Vogel
2023-10-26 17:21:15 +02:00
parent e061f9135a
commit cf2792ce45
4 changed files with 7 additions and 7 deletions

View File

@@ -188,7 +188,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
); );
} }
public function getAspectRatio(): float public function aspectRatio(): float
{ {
return $this->width() / $this->height(); return $this->width() / $this->height();
} }

View File

@@ -77,7 +77,7 @@ class RectangleResizer
return $size->width(); return $size->width();
} }
return (int) round($this->height * $size->getAspectRatio()); return (int) round($this->height * $size->aspectRatio());
} }
protected function getProportionalHeight(SizeInterface $size): int protected function getProportionalHeight(SizeInterface $size): int
@@ -86,7 +86,7 @@ class RectangleResizer
return $size->height(); return $size->height();
} }
return (int) round($this->width / $size->getAspectRatio()); return (int) round($this->width / $size->aspectRatio());
} }
public function resize(SizeInterface $size): SizeInterface public function resize(SizeInterface $size): SizeInterface

View File

@@ -10,7 +10,7 @@ interface SizeInterface
public function setWidth(int $width): SizeInterface; public function setWidth(int $width): SizeInterface;
public function setHeight(int $height): SizeInterface; public function setHeight(int $height): SizeInterface;
public function setPivot(PointInterface $pivot): SizeInterface; public function setPivot(PointInterface $pivot): SizeInterface;
public function getAspectRatio(): float; public function aspectRatio(): float;
public function fitsInto(SizeInterface $size): bool; public function fitsInto(SizeInterface $size): bool;
public function isLandscape(): bool; public function isLandscape(): bool;
public function isPortrait(): bool; public function isPortrait(): bool;

View File

@@ -50,13 +50,13 @@ class RectangleTest extends TestCase
public function testGetAspectRatio() public function testGetAspectRatio()
{ {
$size = new Rectangle(800, 600); $size = new Rectangle(800, 600);
$this->assertEquals(1.333, round($size->getAspectRatio(), 3)); $this->assertEquals(1.333, round($size->aspectRatio(), 3));
$size = new Rectangle(100, 100); $size = new Rectangle(100, 100);
$this->assertEquals(1, $size->getAspectRatio()); $this->assertEquals(1, $size->aspectRatio());
$size = new Rectangle(1920, 1080); $size = new Rectangle(1920, 1080);
$this->assertEquals(1.778, round($size->getAspectRatio(), 3)); $this->assertEquals(1.778, round($size->aspectRatio(), 3));
} }
public function testFitsInto() public function testFitsInto()