diff --git a/src/Geometry/Factories/CircleFactory.php b/src/Geometry/Factories/CircleFactory.php index 74340fd6..118a5b4e 100644 --- a/src/Geometry/Factories/CircleFactory.php +++ b/src/Geometry/Factories/CircleFactory.php @@ -4,6 +4,12 @@ namespace Intervention\Image\Geometry\Factories; class CircleFactory extends EllipseFactory { + /** + * Set the radius of the circle to be produced + * + * @param int $radius + * @return CircleFactory + */ public function radius(int $radius): self { $this->ellipse->setSize($radius * 2, $radius * 2); @@ -11,6 +17,12 @@ class CircleFactory extends EllipseFactory return $this; } + /** + * Set the diameter of the circle to be produced + * + * @param int $diameter + * @return CircleFactory + */ public function diameter(int $diameter): self { $this->ellipse->setSize($diameter, $diameter); diff --git a/src/Geometry/Factories/EllipseFactory.php b/src/Geometry/Factories/EllipseFactory.php index 509539c2..ebcd48a6 100644 --- a/src/Geometry/Factories/EllipseFactory.php +++ b/src/Geometry/Factories/EllipseFactory.php @@ -9,6 +9,13 @@ class EllipseFactory { protected Ellipse $ellipse; + /** + * Create new factory instance + * + * @param Point $pivot + * @param callable|Ellipse $init + * @return void + */ public function __construct(protected Point $pivot, callable|Ellipse $init) { $this->ellipse = is_a($init, Ellipse::class) ? $init : new Ellipse(0, 0, $pivot); @@ -18,6 +25,13 @@ class EllipseFactory } } + /** + * Set the size of the ellipse to be produced + * + * @param int $width + * @param int $height + * @return EllipseFactory + */ public function size(int $width, int $height): self { $this->ellipse->setSize($width, $height); @@ -25,6 +39,12 @@ class EllipseFactory return $this; } + /** + * Set the width of the ellipse to be produced + * + * @param int $width + * @return EllipseFactory + */ public function width(int $width): self { $this->ellipse->setWidth($width); @@ -32,6 +52,12 @@ class EllipseFactory return $this; } + /** + * Set the height of the ellipse to be produced + * + * @param int $height + * @return EllipseFactory + */ public function height(int $height): self { $this->ellipse->setHeight($height); @@ -39,6 +65,12 @@ class EllipseFactory return $this; } + /** + * Set the background color of the ellipse to be produced + * + * @param mixed $color + * @return EllipseFactory + */ public function background(mixed $color): self { $this->ellipse->setBackgroundColor($color); @@ -46,6 +78,13 @@ class EllipseFactory return $this; } + /** + * Set the border color & border size of the ellipse to be produced + * + * @param mixed $color + * @param int $size + * @return EllipseFactory + */ public function border(mixed $color, int $size = 1): self { $this->ellipse->setBorder($color, $size); @@ -53,6 +92,11 @@ class EllipseFactory return $this; } + /** + * Produce the ellipse + * + * @return Ellipse + */ public function __invoke(): Ellipse { return $this->ellipse; diff --git a/src/Geometry/Factories/LineFactory.php b/src/Geometry/Factories/LineFactory.php index db846633..f22bc9aa 100644 --- a/src/Geometry/Factories/LineFactory.php +++ b/src/Geometry/Factories/LineFactory.php @@ -9,6 +9,12 @@ class LineFactory { protected Line $line; + /** + * Create the factory instance + * + * @param callable|Line $init + * @return void + */ public function __construct(callable|Line $init) { $this->line = is_a($init, Line::class) ? $init : new Line(new Point(), new Point()); @@ -18,6 +24,12 @@ class LineFactory } } + /** + * Set the color of the line to be produced + * + * @param mixed $color + * @return LineFactory + */ public function color(mixed $color): self { $this->line->setBackgroundColor($color); @@ -26,6 +38,12 @@ class LineFactory return $this; } + /** + * Set the (background) color of the line to be produced + * + * @param mixed $color + * @return LineFactory + */ public function background(mixed $color): self { $this->line->setBackgroundColor($color); @@ -34,6 +52,13 @@ class LineFactory return $this; } + /** + * Set the border size & border color of the line to be produced + * + * @param mixed $color + * @param int $size + * @return LineFactory + */ public function border(mixed $color, int $size = 1): self { $this->line->setBackgroundColor($color); @@ -43,6 +68,12 @@ class LineFactory return $this; } + /** + * Set the width of the line to be produced + * + * @param int $size + * @return LineFactory + */ public function width(int $size): self { $this->line->setWidth($size); @@ -50,6 +81,13 @@ class LineFactory return $this; } + /** + * Set the coordinates of the starting point of the line to be produced + * + * @param int $x + * @param int $y + * @return LineFactory + */ public function from(int $x, int $y): self { $this->line->setStart(new Point($x, $y)); @@ -57,6 +95,13 @@ class LineFactory return $this; } + /** + * Set the coordinates of the end point of the line to be produced + * + * @param int $x + * @param int $y + * @return LineFactory + */ public function to(int $x, int $y): self { $this->line->setEnd(new Point($x, $y)); @@ -64,6 +109,11 @@ class LineFactory return $this; } + /** + * Produce the line + * + * @return Line + */ public function __invoke(): Line { return $this->line; diff --git a/src/Geometry/Factories/PolygonFactory.php b/src/Geometry/Factories/PolygonFactory.php index e7c501aa..919b8f14 100644 --- a/src/Geometry/Factories/PolygonFactory.php +++ b/src/Geometry/Factories/PolygonFactory.php @@ -9,6 +9,12 @@ class PolygonFactory { protected Polygon $polygon; + /** + * Create new factory instance + * + * @param callable|Polygon $init + * @return void + */ public function __construct(callable|Polygon $init) { $this->polygon = is_a($init, Polygon::class) ? $init : new Polygon([]); @@ -18,6 +24,13 @@ class PolygonFactory } } + /** + * Add a point to the polygon to be produced + * + * @param int $x + * @param int $y + * @return PolygonFactory + */ public function point(int $x, int $y): self { $this->polygon->addPoint(new Point($x, $y)); @@ -25,6 +38,12 @@ class PolygonFactory return $this; } + /** + * Set the background color of the polygon to be produced + * + * @param mixed $color + * @return PolygonFactory + */ public function background(mixed $color): self { $this->polygon->setBackgroundColor($color); @@ -32,6 +51,13 @@ class PolygonFactory return $this; } + /** + * Set the border color & border size of the polygon to be produced + * + * @param mixed $color + * @param int $size + * @return PolygonFactory + */ public function border(mixed $color, int $size = 1): self { $this->polygon->setBorder($color, $size); @@ -39,6 +65,11 @@ class PolygonFactory return $this; } + /** + * Produce the polygon + * + * @return Polygon + */ public function __invoke(): Polygon { return $this->polygon; diff --git a/src/Geometry/Factories/RectangleFactory.php b/src/Geometry/Factories/RectangleFactory.php index ceeb0672..a8edb3ab 100644 --- a/src/Geometry/Factories/RectangleFactory.php +++ b/src/Geometry/Factories/RectangleFactory.php @@ -9,6 +9,13 @@ class RectangleFactory { protected Rectangle $rectangle; + /** + * Create new instance + * + * @param Point $pivot + * @param callable|Rectangle $init + * @return void + */ public function __construct(protected Point $pivot, callable|Rectangle $init) { $this->rectangle = is_a($init, Rectangle::class) ? $init : new Rectangle(0, 0, $pivot); @@ -18,6 +25,13 @@ class RectangleFactory } } + /** + * Set the size of the rectangle to be produced + * + * @param int $width + * @param int $height + * @return RectangleFactory + */ public function size(int $width, int $height): self { $this->rectangle->setSize($width, $height); @@ -25,6 +39,12 @@ class RectangleFactory return $this; } + /** + * Set the width of the rectangle to be produced + * + * @param int $width + * @return RectangleFactory + */ public function width(int $width): self { $this->rectangle->setWidth($width); @@ -32,6 +52,12 @@ class RectangleFactory return $this; } + /** + * Set the height of the rectangle to be produced + * + * @param int $height + * @return RectangleFactory + */ public function height(int $height): self { $this->rectangle->setHeight($height); @@ -39,6 +65,12 @@ class RectangleFactory return $this; } + /** + * Set the background color of the rectangle to be produced + * + * @param mixed $color + * @return RectangleFactory + */ public function background(mixed $color): self { $this->rectangle->setBackgroundColor($color); @@ -46,6 +78,13 @@ class RectangleFactory return $this; } + /** + * Set the border color & border size of the rectangle to be produced + * + * @param mixed $color + * @param int $size + * @return RectangleFactory + */ public function border(mixed $color, int $size = 1): self { $this->rectangle->setBorder($color, $size); @@ -53,6 +92,11 @@ class RectangleFactory return $this; } + /** + * Produce the rectangle + * + * @return Rectangle + */ public function __invoke(): Rectangle { return $this->rectangle;