From 7d8a25afe687366e275791c6f58ff0de17776b20 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 9 Mar 2016 23:13:06 +0100 Subject: [PATCH] Docs --- Utils/Barcode/C128Abstract.php | 190 ++++++++++++++++++++++++++++++++- Utils/Barcode/C128a.php | 73 ++++++++++++- Utils/Barcode/C128b.php | 51 ++++++++- Utils/Barcode/C128c.php | 57 ++++++++++ Utils/Barcode/C25.php | 80 +++++++++++++- Utils/Barcode/C39.php | 74 ++++++++++++- Utils/Barcode/Codebar.php | 80 +++++++++++++- 7 files changed, 595 insertions(+), 10 deletions(-) diff --git a/Utils/Barcode/C128Abstract.php b/Utils/Barcode/C128Abstract.php index 1b81ef8ea..2de5c1c8c 100644 --- a/Utils/Barcode/C128Abstract.php +++ b/Utils/Barcode/C128Abstract.php @@ -1,27 +1,145 @@ + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ namespace phpOMS\Utils\Barcode; use phpOMS\Datatypes\Exception\InvalidEnumValue; +/** + * Code 128 abstract class. + * + * @category Log + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ abstract class C128Abstract { + /** + * Checksum. + * + * @var int + * @since 1.0.0 + */ protected static $CHECKSUM = 0; + /** + * Char weighted array. + * + * @var string[] + * @since 1.0.0 + */ protected static $CODEARRAY = []; + /** + * Code start. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_START = ''; + + /** + * Code end. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_END = ''; + /** + * Orientation. + * + * @var int + * @since 1.0.0 + */ protected $orientation = 0; + + /** + * Barcode height. + * + * @var int + * @since 1.0.0 + */ protected $size = 0; + + /** + * Barcode dimension. + * + * @todo: Implement! + * + * @var int[] + * @since 1.0.0 + */ protected $dimension = ['width' => 0, 'height' => 0]; + + /** + * Content to encrypt. + * + * @var string|int + * @since 1.0.0 + */ protected $content = 0; + + /** + * Show text below barcode. + * + * @var string + * @since 1.0.0 + */ protected $showText = true; - protected $margin = ['top' => 0.0, 'right' => 4, 'bottom' => 0.0, 'left' => 4]; - protected $background = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]; + + /** + * Margin for barcode (padding). + * + * @var int[] + * @since 1.0.0 + */ + protected $margin = ['top' => 0, 'right' => 4, 'bottom' => 0, 'left' => 4]; + + /** + * Background color. + * + * @var int[] + * @since 1.0.0 + */ + protected $background = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0 + + /** + * Front color. + * + * @var int[] + * @since 1.0.0 + */ protected $front = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]; + /** + * Constructor + * + * @param string $content Content to encrypt + * @param int $size Barcode height + * @param int $orientation Orientation of the barcode + * + * @todo: add mirror parameter + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __construct(string $content = '', int $size = 20, int $orientation = OrientationType::HORIZONTAL) { $this->content = $content; @@ -29,6 +147,14 @@ abstract class C128Abstract $this->setOrientation($orientation); } + /** + * Set barcode orientation + * + * @param int $orientation Barcode orientation + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setOrientation(int $orientation) { if (!OrientationType::isValidValue($orientation)) { @@ -38,11 +164,40 @@ abstract class C128Abstract $this->orientation = $orientation; } + /** + * Set content to encrypt + * + * @param string $content Barcode content + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setContent(string $content) { $this->content = $content; } + /** + * Get content + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getContent() : string + { + return $this->content; + } + + /** + * Set barcode height + * + * @param int $size Barcode height + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setSize(int $size) { if ($size < 0) { @@ -52,7 +207,15 @@ abstract class C128Abstract $this->size = $size; } - protected function generateCodeString() + /** + * Generate weighted code string + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + protected function generateCodeString() : string { $keys = array_keys(static::$CODEARRAY); $values = array_flip($keys); @@ -72,6 +235,14 @@ abstract class C128Abstract return $codeString; } + /** + * Get image reference + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function get() { $codeString = static::$CODE_START . $this->generateCodeString() . static::$CODE_END; @@ -79,6 +250,17 @@ abstract class C128Abstract return $this->createImage($codeString, 20); } + /** + * Create barcode image + * + * @param string $codeString Code string to render + * @param int $codeLength Barcode length (based on $codeString) + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ protected function createImage(string $codeString, int $codeLength = 20) { for ($i = 1; $i <= strlen($codeString); $i++) { diff --git a/Utils/Barcode/C128a.php b/Utils/Barcode/C128a.php index bfe9e9227..1871f2b39 100644 --- a/Utils/Barcode/C128a.php +++ b/Utils/Barcode/C128a.php @@ -1,11 +1,47 @@ + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ namespace phpOMS\Utils\Barcode; +/** + * Code 128a class. + * + * @category Log + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ class C128a extends C128Abstract { + /** + * Checksum. + * + * @var int + * @since 1.0.0 + */ protected static $CHECKSUM = 103; + /** + * Char weighted array. + * + * @var string[] + * @since 1.0.0 + */ protected static $CODEARRAY = [ ' ' => '212222', '!' => '222122', '"' => '222221', '#' => '121223', '$' => '121322', '%' => '131222', '&' => '122213', '\'' => '122312', '(' => '132212', ')' => '221213', '*' => '221312', '+' => '231212', @@ -29,14 +65,49 @@ class C128a extends C128Abstract 'Stop' => '2331112', ]; + /** + * Code start. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_START = '211412'; + + /** + * Code end. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_END = '2331112'; + /** + * Constructor + * + * @param string $content Content to encrypt + * @param int $size Barcode height + * @param int $orientation Orientation of the barcode + * + * @todo: add mirror parameter + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __construct(string $content = '', int $size = 20, int $orientation = OrientationType::HORIZONTAL) { parent::__construct(strtoupper($content), $size, $orientation); } + /** + * Set content to encrypt + * + * @param string $content Content to encrypt + * + * @todo: add mirror parameter + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setContent(string $content) { parent::setContent(strtoupper($content)); diff --git a/Utils/Barcode/C128b.php b/Utils/Barcode/C128b.php index 3ec1fc68c..fb42cbcec 100644 --- a/Utils/Barcode/C128b.php +++ b/Utils/Barcode/C128b.php @@ -1,11 +1,47 @@ + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ namespace phpOMS\Utils\Barcode; +/** + * Code 128b class. + * + * @category Log + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ class C128b extends C128Abstract { + /** + * Checksum. + * + * @var int + * @since 1.0.0 + */ protected static $CHECKSUM = 104; + /** + * Char weighted array. + * + * @var string[] + * @since 1.0.0 + */ protected static $CODEARRAY = [ ' ' => '212222', '!' => '222122', '"' => '222221', '#' => '121223', '$' => '121322', '%' => '131222', '&' => '122213', '\'' => '122312', '(' => '132212', ')' => '221213', '*' => '221312', '+' => '231212', @@ -28,6 +64,19 @@ class C128b extends C128Abstract 'Start C' => '211232', 'Stop' => '2331112', ]; + /** + * Code start. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_START = '211214'; + + /** + * Code end. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_END = '2331112'; } diff --git a/Utils/Barcode/C128c.php b/Utils/Barcode/C128c.php index f5f9f375c..64b0ab797 100644 --- a/Utils/Barcode/C128c.php +++ b/Utils/Barcode/C128c.php @@ -1,11 +1,48 @@ + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ namespace phpOMS\Utils\Barcode; +/** + * Code 128c class. + * + * @category Log + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ class C128c extends C128Abstract { + /** + * Checksum. + * + * @var int + * @since 1.0.0 + */ protected static $CHECKSUM = 105; + /** + * Char weighted array. + * + * @var string[] + * @since 1.0.0 + */ protected static $CODEARRAY = [ '00' => '212222', '01' => '222122', '02' => '222221', '03' => '121223', '04' => '121322', '05' => '131222', '06' => '122213', '07' => '122312', '08' => '132212', '09' => '221213', '10' => '221312', '11' => '231212', @@ -28,10 +65,30 @@ class C128c extends C128Abstract 'Stop' => '2331112', ]; + /** + * Code start. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_START = '211232'; + /** + * Code end. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_END = '2331112'; + /** + * Generate weighted code string + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ protected function generateCodeString() { $keys = array_keys(self::$CODEARRAY); diff --git a/Utils/Barcode/C25.php b/Utils/Barcode/C25.php index a07627e71..37322881b 100644 --- a/Utils/Barcode/C25.php +++ b/Utils/Barcode/C25.php @@ -1,20 +1,82 @@ + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ namespace phpOMS\Utils\Barcode; +/** + * Code 2 class. + * + * @category Log + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ class C25 extends C128Abstract { + /** + * Char array. + * + * @var string[] + * @since 1.0.0 + */ protected static $CODEARRAY = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']; + + /** + * Char weighted array. + * + * @var string[] + * @since 1.0.0 + */ protected static $CODEARRAY2 = [ '3-1-1-1-3', '1-3-1-1-3', '3-3-1-1-1', '1-1-3-1-3', '3-1-3-1-1', '1-3-3-1-1', '1-1-1-3-3', '3-1-1-3-1', '1-3-1-3-1', '1-1-3-3-1', ]; + /** + * Code start. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_START = '1111'; + /** + * Code end. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_END = '311'; - public function __construct(string $content = '', int $size = 20, int $orientation = 0) + /** + * Constructor + * + * @param string $content Content to encrypt + * @param int $size Barcode height + * @param int $orientation Orientation of the barcode + * + * @todo: add mirror parameter + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function __construct(string $content = '', int $size = 20, int $orientation = OrientationType::HORIZONTAL) { if(!ctype_digit($content)) { throw new \InvalidArgumentException($content); @@ -23,6 +85,14 @@ class C25 extends C128Abstract parent::__construct($content, $size, $orientation); } + /** + * Set content to encrypt + * + * @param string $content Barcode content + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setContent(string $content) { if(!ctype_digit($content)) { @@ -32,6 +102,14 @@ class C25 extends C128Abstract parent::setContent($content); } + /** + * Generate weighted code string + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ protected function generateCodeString() { $codeString = ''; diff --git a/Utils/Barcode/C39.php b/Utils/Barcode/C39.php index 97049d3ea..550d0b377 100644 --- a/Utils/Barcode/C39.php +++ b/Utils/Barcode/C39.php @@ -1,9 +1,40 @@ + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ namespace phpOMS\Utils\Barcode; +/** + * Code 39 class. + * + * @category Log + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ class C39 extends C128Abstract { + /** + * Char weighted array. + * + * @var string[] + * @since 1.0.0 + */ protected static $CODEARRAY = [ '0' => '111221211', '1' => '211211112', '2' => '112211112', '3' => '212211111', '4' => '111221112', '5' => '211221111', '6' => '112221111', '7' => '111211212', '8' => '211211211', '9' => '112211211', @@ -16,21 +47,60 @@ class C39 extends C128Abstract '/' => '121211121', '+' => '121112121', '%' => '111212121', '*' => '121121211', ]; - + /** + * Code start. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_START = '1211212111'; + /** + * Code end. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_END = '121121211'; - public function __construct(string $content = '', int $size = 20, int $orientation = 0) + /** + * Constructor + * + * @param string $content Content to encrypt + * @param int $size Barcode height + * @param int $orientation Orientation of the barcode + * + * @todo: add mirror parameter + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function __construct(string $content = '', int $size = 20, int $orientation = OrientationType::HORIZONTAL) { parent::__construct(strtoupper($content), $size, $orientation); } + /** + * Set content to encrypt + * + * @param string $content Barcode content + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setContent(string $content) { parent::setContent(strtoupper($content)); } + /** + * Generate weighted code string + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ protected function generateCodeString() { $codeString = ''; diff --git a/Utils/Barcode/Codebar.php b/Utils/Barcode/Codebar.php index 87d04c9d8..d7371b80f 100644 --- a/Utils/Barcode/Codebar.php +++ b/Utils/Barcode/Codebar.php @@ -1,29 +1,107 @@ + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ namespace phpOMS\Utils\Barcode; +/** + * Codebar class. + * + * @category Log + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ class Codebar extends C128Abstract { + /** + * Char array. + * + * @var string[] + * @since 1.0.0 + */ protected static $CODEARRAY = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '$', ':', '/', '.', '+', 'A', 'B', 'C', 'D']; + + /** + * Char weighted array. + * + * @var string[] + * @since 1.0.0 + */ protected static $CODEARRAY2 = [ '1111221', '1112112', '2211111', '1121121', '2111121', '1211112', '1211211', '1221111', '2112111', '1111122', '1112211', '1122111', '2111212', '2121112', '2121211', '1121212', '1122121', '1212112', '1112122', '1112221', ]; + /** + * Code start. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_START = '11221211'; + /** + * Code end. + * + * @var string + * @since 1.0.0 + */ protected static $CODE_END = '1122121'; - public function __construct(string $content = '', int $size = 20, int $orientation = 0) + /** + * Constructor + * + * @param string $content Content to encrypt + * @param int $size Barcode height + * @param int $orientation Orientation of the barcode + * + * @todo: add mirror parameter + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function __construct(string $content = '', int $size = 20, int $orientation = OrientationType::HORIZONTAL) { parent::__construct(strtoupper($content), $size, $orientation); } + /** + * Set content to encrypt + * + * @param string $content Barcode content + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setContent(string $content) { parent::setContent(strtoupper($content)); } + /** + * Generate weighted code string + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ protected function generateCodeString() { $codeString = '';