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

Add doc blocks

This commit is contained in:
Oliver Vogel
2024-01-15 17:28:29 +01:00
parent 23afc7fda2
commit 92135d9889
5 changed files with 181 additions and 0 deletions

View File

@@ -4,6 +4,12 @@ namespace Intervention\Image\Geometry\Factories;
class CircleFactory extends EllipseFactory class CircleFactory extends EllipseFactory
{ {
/**
* Set the radius of the circle to be produced
*
* @param int $radius
* @return CircleFactory
*/
public function radius(int $radius): self public function radius(int $radius): self
{ {
$this->ellipse->setSize($radius * 2, $radius * 2); $this->ellipse->setSize($radius * 2, $radius * 2);
@@ -11,6 +17,12 @@ class CircleFactory extends EllipseFactory
return $this; return $this;
} }
/**
* Set the diameter of the circle to be produced
*
* @param int $diameter
* @return CircleFactory
*/
public function diameter(int $diameter): self public function diameter(int $diameter): self
{ {
$this->ellipse->setSize($diameter, $diameter); $this->ellipse->setSize($diameter, $diameter);

View File

@@ -9,6 +9,13 @@ class EllipseFactory
{ {
protected Ellipse $ellipse; 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) public function __construct(protected Point $pivot, callable|Ellipse $init)
{ {
$this->ellipse = is_a($init, Ellipse::class) ? $init : new Ellipse(0, 0, $pivot); $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 public function size(int $width, int $height): self
{ {
$this->ellipse->setSize($width, $height); $this->ellipse->setSize($width, $height);
@@ -25,6 +39,12 @@ class EllipseFactory
return $this; return $this;
} }
/**
* Set the width of the ellipse to be produced
*
* @param int $width
* @return EllipseFactory
*/
public function width(int $width): self public function width(int $width): self
{ {
$this->ellipse->setWidth($width); $this->ellipse->setWidth($width);
@@ -32,6 +52,12 @@ class EllipseFactory
return $this; return $this;
} }
/**
* Set the height of the ellipse to be produced
*
* @param int $height
* @return EllipseFactory
*/
public function height(int $height): self public function height(int $height): self
{ {
$this->ellipse->setHeight($height); $this->ellipse->setHeight($height);
@@ -39,6 +65,12 @@ class EllipseFactory
return $this; return $this;
} }
/**
* Set the background color of the ellipse to be produced
*
* @param mixed $color
* @return EllipseFactory
*/
public function background(mixed $color): self public function background(mixed $color): self
{ {
$this->ellipse->setBackgroundColor($color); $this->ellipse->setBackgroundColor($color);
@@ -46,6 +78,13 @@ class EllipseFactory
return $this; 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 public function border(mixed $color, int $size = 1): self
{ {
$this->ellipse->setBorder($color, $size); $this->ellipse->setBorder($color, $size);
@@ -53,6 +92,11 @@ class EllipseFactory
return $this; return $this;
} }
/**
* Produce the ellipse
*
* @return Ellipse
*/
public function __invoke(): Ellipse public function __invoke(): Ellipse
{ {
return $this->ellipse; return $this->ellipse;

View File

@@ -9,6 +9,12 @@ class LineFactory
{ {
protected Line $line; protected Line $line;
/**
* Create the factory instance
*
* @param callable|Line $init
* @return void
*/
public function __construct(callable|Line $init) public function __construct(callable|Line $init)
{ {
$this->line = is_a($init, Line::class) ? $init : new Line(new Point(), new Point()); $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 public function color(mixed $color): self
{ {
$this->line->setBackgroundColor($color); $this->line->setBackgroundColor($color);
@@ -26,6 +38,12 @@ class LineFactory
return $this; return $this;
} }
/**
* Set the (background) color of the line to be produced
*
* @param mixed $color
* @return LineFactory
*/
public function background(mixed $color): self public function background(mixed $color): self
{ {
$this->line->setBackgroundColor($color); $this->line->setBackgroundColor($color);
@@ -34,6 +52,13 @@ class LineFactory
return $this; 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 public function border(mixed $color, int $size = 1): self
{ {
$this->line->setBackgroundColor($color); $this->line->setBackgroundColor($color);
@@ -43,6 +68,12 @@ class LineFactory
return $this; return $this;
} }
/**
* Set the width of the line to be produced
*
* @param int $size
* @return LineFactory
*/
public function width(int $size): self public function width(int $size): self
{ {
$this->line->setWidth($size); $this->line->setWidth($size);
@@ -50,6 +81,13 @@ class LineFactory
return $this; 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 public function from(int $x, int $y): self
{ {
$this->line->setStart(new Point($x, $y)); $this->line->setStart(new Point($x, $y));
@@ -57,6 +95,13 @@ class LineFactory
return $this; 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 public function to(int $x, int $y): self
{ {
$this->line->setEnd(new Point($x, $y)); $this->line->setEnd(new Point($x, $y));
@@ -64,6 +109,11 @@ class LineFactory
return $this; return $this;
} }
/**
* Produce the line
*
* @return Line
*/
public function __invoke(): Line public function __invoke(): Line
{ {
return $this->line; return $this->line;

View File

@@ -9,6 +9,12 @@ class PolygonFactory
{ {
protected Polygon $polygon; protected Polygon $polygon;
/**
* Create new factory instance
*
* @param callable|Polygon $init
* @return void
*/
public function __construct(callable|Polygon $init) public function __construct(callable|Polygon $init)
{ {
$this->polygon = is_a($init, Polygon::class) ? $init : new Polygon([]); $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 public function point(int $x, int $y): self
{ {
$this->polygon->addPoint(new Point($x, $y)); $this->polygon->addPoint(new Point($x, $y));
@@ -25,6 +38,12 @@ class PolygonFactory
return $this; return $this;
} }
/**
* Set the background color of the polygon to be produced
*
* @param mixed $color
* @return PolygonFactory
*/
public function background(mixed $color): self public function background(mixed $color): self
{ {
$this->polygon->setBackgroundColor($color); $this->polygon->setBackgroundColor($color);
@@ -32,6 +51,13 @@ class PolygonFactory
return $this; 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 public function border(mixed $color, int $size = 1): self
{ {
$this->polygon->setBorder($color, $size); $this->polygon->setBorder($color, $size);
@@ -39,6 +65,11 @@ class PolygonFactory
return $this; return $this;
} }
/**
* Produce the polygon
*
* @return Polygon
*/
public function __invoke(): Polygon public function __invoke(): Polygon
{ {
return $this->polygon; return $this->polygon;

View File

@@ -9,6 +9,13 @@ class RectangleFactory
{ {
protected Rectangle $rectangle; protected Rectangle $rectangle;
/**
* Create new instance
*
* @param Point $pivot
* @param callable|Rectangle $init
* @return void
*/
public function __construct(protected Point $pivot, callable|Rectangle $init) public function __construct(protected Point $pivot, callable|Rectangle $init)
{ {
$this->rectangle = is_a($init, Rectangle::class) ? $init : new Rectangle(0, 0, $pivot); $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 public function size(int $width, int $height): self
{ {
$this->rectangle->setSize($width, $height); $this->rectangle->setSize($width, $height);
@@ -25,6 +39,12 @@ class RectangleFactory
return $this; return $this;
} }
/**
* Set the width of the rectangle to be produced
*
* @param int $width
* @return RectangleFactory
*/
public function width(int $width): self public function width(int $width): self
{ {
$this->rectangle->setWidth($width); $this->rectangle->setWidth($width);
@@ -32,6 +52,12 @@ class RectangleFactory
return $this; return $this;
} }
/**
* Set the height of the rectangle to be produced
*
* @param int $height
* @return RectangleFactory
*/
public function height(int $height): self public function height(int $height): self
{ {
$this->rectangle->setHeight($height); $this->rectangle->setHeight($height);
@@ -39,6 +65,12 @@ class RectangleFactory
return $this; return $this;
} }
/**
* Set the background color of the rectangle to be produced
*
* @param mixed $color
* @return RectangleFactory
*/
public function background(mixed $color): self public function background(mixed $color): self
{ {
$this->rectangle->setBackgroundColor($color); $this->rectangle->setBackgroundColor($color);
@@ -46,6 +78,13 @@ class RectangleFactory
return $this; 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 public function border(mixed $color, int $size = 1): self
{ {
$this->rectangle->setBorder($color, $size); $this->rectangle->setBorder($color, $size);
@@ -53,6 +92,11 @@ class RectangleFactory
return $this; return $this;
} }
/**
* Produce the rectangle
*
* @return Rectangle
*/
public function __invoke(): Rectangle public function __invoke(): Rectangle
{ {
return $this->rectangle; return $this->rectangle;