Skip to content

Commit

Permalink
More typehinting
Browse files Browse the repository at this point in the history
  • Loading branch information
casperbakker committed Jul 25, 2023
1 parent 622a0c7 commit d30174b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/BarcodeGeneratorDynamicHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class BarcodeGeneratorDynamicHTML extends BarcodeGenerator
* This 'dynamic' version uses percentage based widths and heights, resulting in a vector-y qualitative result.
*
* @param string $barcode code to print
* @param string $type type of barcode
* @param BarcodeGenerator::Type_* $type (string) type of barcode
* @param string $foregroundColor Foreground color for bar elements as '#333' or 'orange' for example (background is transparent).
* @return string HTML code.
*/
public function getBarcode($barcode, $type, string $foregroundColor = 'black')
public function getBarcode(string $barcode, $type, string $foregroundColor = 'black'): string
{
$barcodeData = $this->getBarcodeData($barcode, $type);

Expand Down
4 changes: 2 additions & 2 deletions src/BarcodeGeneratorHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ class BarcodeGeneratorHTML extends BarcodeGenerator
* This original version uses pixel based widths and heights. Use Dynamic HTML version for better quality representation.
*
* @param string $barcode code to print
* @param string $type type of barcode
* @param BarcodeGenerator::Type_* $type (string) type of barcode
* @param int $widthFactor Width of a single bar element in pixels.
* @param int $height Height of a single bar element in pixels.
* @param string $foregroundColor Foreground color for bar elements as '#333' or 'orange' for example (background is transparent).
* @return string HTML code.
*/
public function getBarcode($barcode, $type, int $widthFactor = 2, int $height = 30, string $foregroundColor = 'black')
public function getBarcode($barcode, $type, int $widthFactor = 2, int $height = 30, string $foregroundColor = 'black'): string
{
$barcodeData = $this->getBarcodeData($barcode, $type);

Expand Down
7 changes: 5 additions & 2 deletions src/BarcodeGeneratorPNG.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class BarcodeGeneratorPNG extends BarcodeGenerator
{
protected $useImagick = true;

/**
* @throws BarcodeException
*/
public function __construct()
{
// Auto switch between GD and Imagick based on what is installed
Expand Down Expand Up @@ -43,13 +46,13 @@ public function useGd()
* Return a PNG image representation of barcode (requires GD or Imagick library).
*
* @param string $barcode code to print
* @param string $type type of barcode:
* @param BarcodeGenerator::Type_* $type (string) type of barcode
* @param int $widthFactor Width of a single bar element in pixels.
* @param int $height Height of a single bar element in pixels.
* @param array $foregroundColor RGB (0-255) foreground color for bar elements (background is transparent).
* @return string image data or false in case of error.
*/
public function getBarcode($barcode, $type, int $widthFactor = 2, int $height = 30, array $foregroundColor = [0, 0, 0])
public function getBarcode(string $barcode, $type, int $widthFactor = 2, int $height = 30, array $foregroundColor = [0, 0, 0]): string
{
$barcodeData = $this->getBarcodeData($barcode, $type);
$width = round($barcodeData->getWidth() * $widthFactor);
Expand Down
2 changes: 1 addition & 1 deletion src/BarcodeGeneratorSVG.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BarcodeGeneratorSVG extends BarcodeGenerator
* @return string SVG code.
* @public
*/
public function getBarcode(string $barcode, $type, float $widthFactor = 2, float $height = 30, string $foregroundColor = 'black')
public function getBarcode(string $barcode, $type, float $widthFactor = 2, float $height = 30, string $foregroundColor = 'black'): string
{
$barcodeData = $this->getBarcodeData($barcode, $type);

Expand Down

0 comments on commit d30174b

Please sign in to comment.