diff --git a/Utils/Barcode/C128Abstract.php b/Utils/Barcode/C128Abstract.php index c5d38cd5f..1b81ef8ea 100644 --- a/Utils/Barcode/C128Abstract.php +++ b/Utils/Barcode/C128Abstract.php @@ -22,7 +22,7 @@ abstract class C128Abstract protected $background = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]; protected $front = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]; - public function __construct(string $content = '', int $size = 20, int $orientation = 0) + public function __construct(string $content = '', int $size = 20, int $orientation = OrientationType::HORIZONTAL) { $this->content = $content; $this->setSize($size); @@ -54,27 +54,27 @@ abstract class C128Abstract protected function generateCodeString() { - $keys = array_keys(self::$CODEARRAY); + $keys = array_keys(static::$CODEARRAY); $values = array_flip($keys); $codeString = ''; $length = strlen($this->content); - $checksum = self::$CHECKSUM; + $checksum = static::$CHECKSUM; - for ($pos = 1; $pos <= $length; $pos += 2) { + for ($pos = 1; $pos <= $length; $pos++) { $activeKey = substr($this->content, ($pos - 1), 1); - $codeString .= self::$CODEARRAY[$activeKey]; - $checksum = ($checksum + ($values[$activeKey] * $pos)); + $codeString .= static::$CODEARRAY[$activeKey]; + $checksum += $values[$activeKey] * $pos; } - $codeString .= self::$CODEARRAY[$keys[($checksum - (intval($checksum / 103) * 103))]]; - $codeString = self::$CODE_START . $codeString . self::$CODE_END; + $codeString .= static::$CODEARRAY[$keys[($checksum - (intval($checksum / 103) * 103))]]; + $codeString = static::$CODE_START . $codeString . static::$CODE_END; return $codeString; } public function get() { - $codeString = self::$CODE_START . $this->generateCodeString() . self::$CODE_END; + $codeString = static::$CODE_START . $this->generateCodeString() . static::$CODE_END; return $this->createImage($codeString, 20); } diff --git a/Utils/Barcode/C128a.php b/Utils/Barcode/C128a.php index 4ec82cd7a..bfe9e9227 100644 --- a/Utils/Barcode/C128a.php +++ b/Utils/Barcode/C128a.php @@ -32,7 +32,7 @@ class C128a extends C128Abstract protected static $CODE_START = '211412'; protected static $CODE_END = '2331112'; - public function __construct(string $content = '', int $size = 20, int $orientation = 0) + public function __construct(string $content = '', int $size = 20, int $orientation = OrientationType::HORIZONTAL) { parent::__construct(strtoupper($content), $size, $orientation); } diff --git a/Utils/Barcode/C128c.php b/Utils/Barcode/C128c.php index fe86d835d..f5f9f375c 100644 --- a/Utils/Barcode/C128c.php +++ b/Utils/Barcode/C128c.php @@ -49,7 +49,7 @@ class C128c extends C128Abstract } $codeString .= self::$CODEARRAY[$activeKey]; - $checksum = ($checksum + ($values[$activeKey] * $checkPos)); + $checksum += $values[$activeKey] * $checkPos; $checkPos++; }