diff --git a/src/Barcode.php b/src/Barcode.php index a39b382..5b210b3 100644 --- a/src/Barcode.php +++ b/src/Barcode.php @@ -14,6 +14,7 @@ public function __construct(string $barcode) $this->barcode = $barcode; } + // Add a bar to the barcode, either a bar or a space, at the right side of the barcode public function addBar(BarcodeBar $bar): void { $this->bars[] = $bar; diff --git a/src/BarcodeBar.php b/src/BarcodeBar.php index 58a881f..28bd595 100644 --- a/src/BarcodeBar.php +++ b/src/BarcodeBar.php @@ -2,6 +2,7 @@ namespace Picqer\Barcode; +// Represents a single bar or space in a barcode readonly class BarcodeBar { protected int $width; diff --git a/src/Renderers/DynamicHtmlRenderer.php b/src/Renderers/DynamicHtmlRenderer.php index 51ea1a0..66a3e52 100644 --- a/src/Renderers/DynamicHtmlRenderer.php +++ b/src/Renderers/DynamicHtmlRenderer.php @@ -36,8 +36,10 @@ public function render(Barcode $barcode): string return $html; } - public function setForegroundColor(string $color): void + public function setForegroundColor(string $color): self { $this->foregroundColor = $color; + + return $this; } } diff --git a/src/Renderers/HtmlRenderer.php b/src/Renderers/HtmlRenderer.php index 517908e..77ba389 100644 --- a/src/Renderers/HtmlRenderer.php +++ b/src/Renderers/HtmlRenderer.php @@ -36,8 +36,10 @@ public function render(Barcode $barcode, float $width = 200, float $height = 30) return $html; } - public function setForegroundColor(string $color): void + public function setForegroundColor(string $color): self { $this->foregroundColor = $color; + + return $this; } } diff --git a/src/Renderers/PngRenderer.php b/src/Renderers/PngRenderer.php index 22cfcc8..8297d88 100644 --- a/src/Renderers/PngRenderer.php +++ b/src/Renderers/PngRenderer.php @@ -32,17 +32,19 @@ public function __construct() /** * Force the use of Imagick image extension */ - public function useImagick(): void + public function useImagick(): self { $this->useImagick = true; + return $this; } /** * Force the use of the GD image library */ - public function useGd(): void + public function useGd(): self { $this->useImagick = false; + return $this; } public function render(Barcode $barcode, int $widthFactor = 2, int $height = 30): string @@ -88,9 +90,11 @@ public function render(Barcode $barcode, int $widthFactor = 2, int $height = 30) } } - public function setForegroundColor(array $color): void + public function setForegroundColor(array $color): self { $this->foregroundColor = $color; + + return $this; } protected function createGdImageObject(int $width, int $height) diff --git a/src/Renderers/SvgRenderer.php b/src/Renderers/SvgRenderer.php index 6587d99..6af44b3 100644 --- a/src/Renderers/SvgRenderer.php +++ b/src/Renderers/SvgRenderer.php @@ -49,17 +49,19 @@ public function render(Barcode $barcode, float $width = 200, float $height = 30) return $svg; } - public function setForegroundColor(string $color): void + public function setForegroundColor(string $color): self { $this->foregroundColor = $color; + return $this; } - public function setSvgType(string $svgType): void + public function setSvgType(string $svgType): self { if (! in_array($svgType, [self::TYPE_SVG_INLINE, self::TYPE_SVG_STANDALONE])) { throw new InvalidOptionException(); } $this->svgType = $svgType; + return $this; } }