diff -r 5a6b6e770365 -r 68c69c656a2c web/lib/Zend/Barcode/Object/ObjectAbstract.php --- a/web/lib/Zend/Barcode/Object/ObjectAbstract.php Thu May 07 15:10:09 2015 +0200 +++ b/web/lib/Zend/Barcode/Object/ObjectAbstract.php Thu May 07 15:16:02 2015 +0200 @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Barcode * @subpackage Object - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: ObjectAbstract.php 24593 2012-01-05 20:35:02Z matthew $ + * @version $Id$ */ /** @@ -25,55 +25,63 @@ * * @category Zend * @package Zend_Barcode - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Barcode_Object_ObjectAbstract { /** * Namespace of the barcode for autoloading + * * @var string */ protected $_barcodeNamespace = 'Zend_Barcode_Object'; /** * Set of drawing instructions + * * @var array */ protected $_instructions = array(); /** * Barcode type + * * @var string */ protected $_type = null; /** * Height of the object + * * @var integer */ protected $_height = null; /** * Width of the object + * * @var integer */ protected $_width = null; /** * Height of the bar + * * @var integer */ protected $_barHeight = 50; /** * Width of a thin bar + * * @var integer */ protected $_barThinWidth = 1; /** * Width of a thick bar + * * @var integer */ protected $_barThickWidth = 3; @@ -81,42 +89,49 @@ /** * Factor to multiply bar and font measure * (barHeight, barThinWidth, barThickWidth & fontSize) + * * @var integer */ protected $_factor = 1; /** * Font and bars color of the object + * * @var integer */ protected $_foreColor = 0x000000; /** * Background color of the object + * * @var integer */ protected $_backgroundColor = 0xFFFFFF; /** * Activate/deactivate border of the object + * * @var boolean */ protected $_withBorder = false; /** * Activate/deactivate drawing of quiet zones + * * @var boolean */ protected $_withQuietZones = true; /** * Force quiet zones even if + * * @var boolean */ protected $_mandatoryQuietZones = false; /** * Orientation of the barcode in degrees + * * @var float */ protected $_orientation = 0; @@ -124,6 +139,7 @@ /** * Offset from the top the object * (calculated from the orientation) + * * @var integer */ protected $_offsetTop = null; @@ -131,24 +147,28 @@ /** * Offset from the left the object * (calculated from the orientation) + * * @var integer */ protected $_offsetLeft = null; /** * Text to display + * * @var string */ protected $_text = null; /** * Display (or not) human readable text + * * @var boolean */ protected $_drawText = true; /** * Adjust (or not) position of human readable characters with barcode + * * @var boolean */ protected $_stretchText = false; @@ -157,30 +177,35 @@ * Font resource * - integer (1 to 5): corresponds to GD included fonts * - string: corresponds to path of a TTF font + * * @var integer|string */ protected $_font = null; /** * Font size + * * @var float */ protected $_fontSize = 10; /** * Drawing of checksum + * * @var boolean */ protected $_withChecksum = false; /** * Drawing of checksum inside text + * * @var boolean */ protected $_withChecksumInText = false; /** * Fix barcode length (numeric or string like 'even') + * * @var $_barcodeLength integer | string */ protected $_barcodeLength = null; @@ -188,6 +213,7 @@ /** * Activate automatic addition of leading zeros * if barcode length is fixed + * * @var $_addLeadingZeros boolean */ protected $_addLeadingZeros = true; @@ -195,26 +221,29 @@ /** * Activation of mandatory checksum * to deactivate unauthorized modification + * * @var $_mandatoryChecksum boolean */ protected $_mandatoryChecksum = false; /** * Character used to substitute checksum character for validation + * * @var $_substituteChecksumCharacter mixed */ protected $_substituteChecksumCharacter = 0; /** * TTF font name: can be set before instanciation of the object + * * @var string */ protected static $_staticFont = null; /** * Constructor + * * @param array|Zend_Config $options - * @return void */ public function __construct($options = null) { @@ -228,7 +257,9 @@ if (is_array($options)) { $this->setOptions($options); } - $this->_type = strtolower(substr(get_class($this), strlen($this->_barcodeNamespace) + 1)); + $this->_type = strtolower( + substr(get_class($this), strlen($this->_barcodeNamespace) + 1) + ); if ($this->_mandatoryChecksum) { $this->_withChecksum = true; $this->_withChecksumInText = true; @@ -237,7 +268,6 @@ /** * Set default options for particular object - * @return void */ protected function _getDefaultOptions() { @@ -245,8 +275,9 @@ /** * Set barcode state from options array + * * @param array $options - * @return Zend_Barcode_Object + * @return $this */ public function setOptions($options) { @@ -261,8 +292,9 @@ /** * Set barcode state from config object + * * @param Zend_Config $config - * @return Zend_Barcode_Object + * @return $this */ public function setConfig(Zend_Config $config) { @@ -273,7 +305,7 @@ * Set barcode namespace for autoloading * * @param string $namespace - * @return Zend_Barcode_Object + * @return $this */ public function setBarcodeNamespace($namespace) { @@ -293,6 +325,7 @@ /** * Retrieve type of barcode + * * @return string */ public function getType() @@ -302,9 +335,10 @@ /** * Set height of the barcode bar + * * @param integer $value - * @return Zend_Barcode_Object - * @throw Zend_Barcode_Object_Exception + * @return $this + * @throws Zend_Barcode_Object_Exception */ public function setBarHeight($value) { @@ -320,6 +354,7 @@ /** * Get height of the barcode bar + * * @return integer */ public function getBarHeight() @@ -329,9 +364,10 @@ /** * Set thickness of thin bar + * * @param integer $value - * @return Zend_Barcode_Object - * @throw Zend_Barcode_Object_Exception + * @return $this + * @throws Zend_Barcode_Object_Exception */ public function setBarThinWidth($value) { @@ -347,6 +383,7 @@ /** * Get thickness of thin bar + * * @return integer */ public function getBarThinWidth() @@ -356,9 +393,10 @@ /** * Set thickness of thick bar + * * @param integer $value - * @return Zend_Barcode_Object - * @throw Zend_Barcode_Object_Exception + * @return $this + * @throws Zend_Barcode_Object_Exception */ public function setBarThickWidth($value) { @@ -374,6 +412,7 @@ /** * Get thickness of thick bar + * * @return integer */ public function getBarThickWidth() @@ -384,9 +423,10 @@ /** * Set factor applying to * thinBarWidth - thickBarWidth - barHeight - fontSize - * @param float $value - * @return Zend_Barcode_Object - * @throw Zend_Barcode_Object_Exception + * + * @param int|float|string|bool $value + * @return $this + * @throws Zend_Barcode_Object_Exception */ public function setFactor($value) { @@ -403,6 +443,7 @@ /** * Get factor applying to * thinBarWidth - thickBarWidth - barHeight - fontSize + * * @return integer */ public function getFactor() @@ -412,9 +453,10 @@ /** * Set color of the barcode and text + * * @param string $value - * @return Zend_Barcode_Object - * @throw Zend_Barcode_Object_Exception + * @return $this + * @throws Zend_Barcode_Object_Exception */ public function setForeColor($value) { @@ -433,6 +475,7 @@ /** * Retrieve color of the barcode and text + * * @return unknown */ public function getForeColor() @@ -442,9 +485,10 @@ /** * Set the color of the background + * * @param integer $value - * @return Zend_Barcode_Object - * @throw Zend_Barcode_Object_Exception + * @return $this + * @throws Zend_Barcode_Object_Exception */ public function setBackgroundColor($value) { @@ -463,6 +507,7 @@ /** * Retrieve background color of the image + * * @return integer */ public function getBackgroundColor() @@ -472,8 +517,9 @@ /** * Activate/deactivate drawing of the bar + * * @param boolean $value - * @return Zend_Barcode_Object + * @return $this */ public function setWithBorder($value) { @@ -483,6 +529,7 @@ /** * Retrieve if border are draw or not + * * @return boolean */ public function getWithBorder() @@ -492,8 +539,9 @@ /** * Activate/deactivate drawing of the quiet zones + * * @param boolean $value - * @return Zend_Barcode_Object + * @return $this */ public function setWithQuietZones($value) { @@ -503,6 +551,7 @@ /** * Retrieve if quiet zones are draw or not + * * @return boolean */ public function getWithQuietZones() @@ -512,30 +561,35 @@ /** * Allow fast inversion of font/bars color and background color - * @return Zend_Barcode_Object + * + * @return $this */ public function setReverseColor() { $tmp = $this->_foreColor; $this->_foreColor = $this->_backgroundColor; $this->_backgroundColor = $tmp; + return $this; } /** * Set orientation of barcode and text - * @param float $value - * @return Zend_Barcode_Object - * @throw Zend_Barcode_Object_Exception + * + * @param int|float|string|bool $value + * @return $this + * @throws Zend_Barcode_Object_Exception */ public function setOrientation($value) { - $this->_orientation = floatval($value) - floor(floatval($value) / 360) * 360; + $value = floatval($value); + $this->_orientation = $value - floor($value / 360) * 360; return $this; } /** * Retrieve orientation of barcode and text + * * @return float */ public function getOrientation() @@ -545,8 +599,9 @@ /** * Set text to encode + * * @param string $value - * @return Zend_Barcode_Object + * @return $this */ public function setText($value) { @@ -556,6 +611,7 @@ /** * Retrieve text to encode + * * @return string */ public function getText() @@ -569,8 +625,10 @@ /** * Automatically add leading zeros if barcode length is fixed - * @param string $text + * + * @param string $text * @param boolean $withoutChecksum + * @return string */ protected function _addLeadingZeros($text, $withoutChecksum = false) { @@ -592,6 +650,7 @@ /** * Retrieve text to encode + * * @return string */ public function getRawText() @@ -601,6 +660,7 @@ /** * Retrieve text to display + * * @return string */ public function getTextToDisplay() @@ -614,8 +674,9 @@ /** * Activate/deactivate drawing of text to encode + * * @param boolean $value - * @return Zend_Barcode_Object + * @return $this */ public function setDrawText($value) { @@ -625,6 +686,7 @@ /** * Retrieve if drawing of text to encode is enabled + * * @return boolean */ public function getDrawText() @@ -635,9 +697,10 @@ /** * Activate/deactivate the adjustment of the position * of the characters to the position of the bars + * * @param boolean $value - * @return Zend_Barcode_Object - * @throw Zend_Barcode_Object_Exception + * @return $this + * @throws Zend_Barcode_Object_Exception */ public function setStretchText($value) { @@ -648,6 +711,7 @@ /** * Retrieve if the adjustment of the position of the characters * to the position of the bars is enabled + * * @return boolean */ public function getStretchText() @@ -659,8 +723,9 @@ * Activate/deactivate the automatic generation * of the checksum character * added to the barcode text + * * @param boolean $value - * @return Zend_Barcode_Object + * @return $this */ public function setWithChecksum($value) { @@ -673,6 +738,7 @@ /** * Retrieve if the checksum character is automatically * added to the barcode text + * * @return boolean */ public function getWithChecksum() @@ -684,21 +750,24 @@ * Activate/deactivate the automatic generation * of the checksum character * added to the barcode text + * * @param boolean $value - * @return Zend_Barcode_Object - * @throw Zend_Barcode_Object_Exception + * @return $this + * @throws Zend_Barcode_Object_Exception */ public function setWithChecksumInText($value) { if (!$this->_mandatoryChecksum) { $this->_withChecksumInText = (bool) $value; } + return $this; } /** * Retrieve if the checksum character is automatically * added to the barcode text + * * @return boolean */ public function getWithChecksumInText() @@ -708,8 +777,8 @@ /** * Set the font for all instances of barcode + * * @param string $font - * @return void */ public static function setBarcodeFont($font) { @@ -722,9 +791,10 @@ * Set the font: * - if integer between 1 and 5, use gd built-in fonts * - if string, $value is assumed to be the path to a TTF font + * * @param integer|string $value - * @return Zend_Barcode_Object - * @throw Zend_Barcode_Object_Exception + * @return $this + * @throws Zend_Barcode_Object_Exception */ public function setFont($value) { @@ -745,16 +815,19 @@ $this->_font = $value; } else { require_once 'Zend/Barcode/Object/Exception.php'; - throw new Zend_Barcode_Object_Exception(sprintf( - 'Invalid font "%s" provided to setFont()', - $value - )); + throw new Zend_Barcode_Object_Exception( + sprintf( + 'Invalid font "%s" provided to setFont()', + $value + ) + ); } return $this; } /** * Retrieve the font + * * @return integer|string */ public function getFont() @@ -764,9 +837,10 @@ /** * Set the size of the font in case of TTF + * * @param float $value - * @return Zend_Barcode_Object - * @throw Zend_Barcode_Object_Exception + * @return $this + * @throws Zend_Barcode_Object_Exception */ public function setFontSize($value) { @@ -788,6 +862,7 @@ /** * Retrieve the size of the font in case of TTF + * * @return float */ public function getFontSize() @@ -798,6 +873,7 @@ /** * Quiet zone before first bar * and after the last bar + * * @return integer */ public function getQuietZone() @@ -811,6 +887,7 @@ /** * Add an instruction in the array of instructions + * * @param array $instruction */ protected function _addInstruction(array $instruction) @@ -820,6 +897,7 @@ /** * Retrieve the set of drawing instructions + * * @return array */ public function getInstructions() @@ -829,7 +907,8 @@ /** * Add a polygon drawing instruction in the set of instructions - * @param array $points + * + * @param array $points * @param integer $color * @param boolean $filled */ @@ -838,23 +917,26 @@ if ($color === null) { $color = $this->_foreColor; } - $this->_addInstruction(array( - 'type' => 'polygon', - 'points' => $points, - 'color' => $color, - 'filled' => $filled, - )); + $this->_addInstruction( + array( + 'type' => 'polygon', + 'points' => $points, + 'color' => $color, + 'filled' => $filled, + ) + ); } /** * Add a text drawing instruction in the set of instructions - * @param string $text - * @param float $size - * @param array $position - * @param string $font - * @param integer $color - * @param string $alignment - * @param float $orientation + * + * @param string $text + * @param float $size + * @param array $position + * @param string $font + * @param integer $color + * @param string $alignment + * @param float|int $orientation */ protected function _addText( $text, @@ -868,21 +950,24 @@ if ($color === null) { $color = $this->_foreColor; } - $this->_addInstruction(array( - 'type' => 'text', - 'text' => $text, - 'size' => $size, - 'position' => $position, - 'font' => $font, - 'color' => $color, - 'alignment' => $alignment, - 'orientation' => $orientation, - )); + $this->_addInstruction( + array( + 'type' => 'text', + 'text' => $text, + 'size' => $size, + 'position' => $position, + 'font' => $font, + 'color' => $color, + 'alignment' => $alignment, + 'orientation' => $orientation, + ) + ); } /** * Checking of parameters after all settings - * @return void + * + * @return bool */ public function checkParams() { @@ -894,8 +979,9 @@ /** * Check if a text is really provided to barcode - * @return void - * @throw Zend_Barcode_Object_Exception + * + * @param string|null $value + * @throws Zend_Barcode_Object_Exception */ protected function _checkText($value = null) { @@ -913,29 +999,31 @@ /** * Check the ratio between the thick and the thin bar - * @param integer $min - * @param integer $max - * @return void - * @throw Zend_Barcode_Object_Exception + * + * @param int $min + * @param int $max + * @throws Zend_Barcode_Object_Exception */ protected function _checkRatio($min = 2, $max = 3) { $ratio = $this->_barThickWidth / $this->_barThinWidth; if (!($ratio >= $min && $ratio <= $max)) { require_once 'Zend/Barcode/Object/Exception.php'; - throw new Zend_Barcode_Object_Exception(sprintf( - 'Ratio thick/thin bar must be between %0.1f and %0.1f (actual %0.3f)', - $min, - $max, - $ratio - )); + throw new Zend_Barcode_Object_Exception( + sprintf( + 'Ratio thick/thin bar must be between %0.1f and %0.1f (actual %0.3f)', + $min, + $max, + $ratio + ) + ); } } /** * Drawing with an angle is just allow TTF font - * @return void - * @throw Zend_Barcode_Object_Exception + * + * @throws Zend_Barcode_Object_Exception */ protected function _checkFontAndOrientation() { @@ -948,8 +1036,8 @@ } /** - * Width of the result image - * (before any rotation) + * Width of the result image (before any rotation) + * * @return integer */ protected function _calculateWidth() @@ -961,13 +1049,15 @@ /** * Calculate the width of the barcode + * * @return integer */ abstract protected function _calculateBarcodeWidth(); /** * Height of the result object - * @return integer + * + * @return int */ protected function _calculateHeight() { @@ -978,7 +1068,8 @@ /** * Height of the barcode - * @return integer + * + * @return int */ protected function _calculateBarcodeHeight() { @@ -988,33 +1079,55 @@ $textHeight += $this->_fontSize; $extraHeight = 2; } - return ($this->_barHeight + $textHeight) * $this->_factor + $extraHeight; + + return ($this->_barHeight + $textHeight) * $this->_factor + + $extraHeight; } /** * Get height of the result object - * @return integer + * + * @param bool $recalculate + * @return int */ public function getHeight($recalculate = false) { if ($this->_height === null || $recalculate) { $this->_height = - abs($this->_calculateHeight() * cos($this->_orientation / 180 * pi())) - + abs($this->_calculateWidth() * sin($this->_orientation / 180 * pi())); + abs( + $this->_calculateHeight() * cos( + $this->_orientation / 180 * pi() + ) + ) + + abs( + $this->_calculateWidth() * sin( + $this->_orientation / 180 * pi() + ) + ); } return $this->_height; } /** * Get width of the result object - * @return integer + * + * @param bool $recalculate + * @return int */ public function getWidth($recalculate = false) { if ($this->_width === null || $recalculate) { $this->_width = - abs($this->_calculateWidth() * cos($this->_orientation / 180 * pi())) - + abs($this->_calculateHeight() * sin($this->_orientation / 180 * pi())); + abs( + $this->_calculateWidth() * cos( + $this->_orientation / 180 * pi() + ) + ) + + abs( + $this->_calculateHeight() * sin( + $this->_orientation / 180 * pi() + ) + ); } return $this->_width; } @@ -1022,7 +1135,8 @@ /** * Calculate the offset from the left of the object * if an orientation is activated - * @param boolean $recalculate + * + * @param bool $recalculate * @return float */ public function getOffsetLeft($recalculate = false) @@ -1049,7 +1163,8 @@ /** * Calculate the offset from the top of the object * if an orientation is activated - * @param boolean $recalculate + * + * @param bool $recalculate * @return float */ public function getOffsetTop($recalculate = false) @@ -1075,9 +1190,10 @@ /** * Apply rotation on a point in X/Y dimensions - * @param float $x1 x-position before rotation - * @param float $y1 y-position before rotation - * @return array Array of two elements corresponding to the new XY point + * + * @param float $x1 x-position before rotation + * @param float $y1 y-position before rotation + * @return array Array of two elements corresponding to the new XY point */ protected function _rotate($x1, $y1) { @@ -1087,11 +1203,16 @@ $y2 = $y1 * cos($this->_orientation / 180 * pi()) + $x1 * sin($this->_orientation / 180 * pi()) + $this->getOffsetTop(); - return array(intval($x2) , intval($y2)); + + return array( + intval($x2), + intval($y2) + ); } /** * Complete drawing of the barcode + * * @return array Table of instructions */ public function draw() @@ -1105,7 +1226,6 @@ /** * Draw the barcode - * @return void */ protected function _drawBarcode() { @@ -1124,12 +1244,14 @@ ); $point4 = $this->_rotate($this->_calculateWidth() - 1, 0); - $this->_addPolygon(array( - $point1, - $point2, - $point3, - $point4 - ), $this->_backgroundColor); + $this->_addPolygon( + array( + $point1, + $point2, + $point3, + $point4 + ), $this->_backgroundColor + ); $xpos += $this->getQuietZone(); $barLength = $this->_barHeight * $this->_factor; @@ -1147,12 +1269,14 @@ $xpos + $width - 1, $ypos + $bar[2] * $barLength ); - $this->_addPolygon(array( - $point1, - $point2, - $point3, - $point4, - )); + $this->_addPolygon( + array( + $point1, + $point2, + $point3, + $point4, + ) + ); } $xpos += $width; } @@ -1162,7 +1286,6 @@ /** * Partial function to draw border - * @return void */ protected function _drawBorder() { @@ -1174,19 +1297,20 @@ $this->_calculateHeight() - 1 ); $point4 = $this->_rotate(0, $this->_calculateHeight() - 1); - $this->_addPolygon(array( - $point1, - $point2, - $point3, - $point4, - $point1, - ), $this->_foreColor, false); + $this->_addPolygon( + array( + $point1, + $point2, + $point3, + $point4, + $point1, + ), $this->_foreColor, false + ); } } /** * Partial function to draw text - * @return void */ protected function _drawText() { @@ -1231,8 +1355,8 @@ /** * Check for invalid characters - * @param string $value Text to be ckecked - * @return void + * + * @param string $value Text to be ckecked */ public function validateText($value) { @@ -1241,17 +1365,21 @@ /** * Standard validation for most of barcode objects + * * @param string $value * @param array $options + * @throws Zend_Barcode_Object_Exception */ protected function _validateText($value, $options = array()) { $validatorName = (isset($options['validator'])) ? $options['validator'] : $this->getType(); - $validator = new Zend_Validate_Barcode(array( - 'adapter' => $validatorName, - 'checksum' => false, - )); + $validator = new Zend_Validate_Barcode( + array( + 'adapter' => $validatorName, + 'checksum' => false, + ) + ); $checksumCharacter = ''; $withChecksum = false; @@ -1260,7 +1388,8 @@ $withChecksum = true; } - $value = $this->_addLeadingZeros($value, $withChecksum) . $checksumCharacter; + $value = $this->_addLeadingZeros($value, $withChecksum) + . $checksumCharacter; if (!$validator->isValid($value)) { $message = implode("\n", $validator->getMessages()); @@ -1291,15 +1420,11 @@ /** * Checking of parameters after all settings - * - * @return void */ abstract protected function _checkParams(); /** * Allow each child to draw something else - * - * @return void */ protected function _preDrawBarcode() { @@ -1308,8 +1433,6 @@ /** * Allow each child to draw something else * (ex: bearer bars in interleaved 2 of 5 code) - * - * @return void */ protected function _postDrawBarcode() {