Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit cfef1b7

Browse files
committed
CS fixes in Zend_Barcode_Object_ObjectAbstract
1 parent 51904b6 commit cfef1b7

File tree

1 file changed

+100
-58
lines changed

1 file changed

+100
-58
lines changed

library/Zend/Barcode/Object/ObjectAbstract.php

Lines changed: 100 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ public function __construct($options = null)
257257
if (is_array($options)) {
258258
$this->setOptions($options);
259259
}
260-
$this->_type = strtolower(substr(get_class($this), strlen($this->_barcodeNamespace) + 1));
260+
$this->_type = strtolower(
261+
substr(get_class($this), strlen($this->_barcodeNamespace) + 1)
262+
);
261263
if ($this->_mandatoryChecksum) {
262264
$this->_withChecksum = true;
263265
$this->_withChecksumInText = true;
@@ -580,7 +582,8 @@ public function setReverseColor()
580582
*/
581583
public function setOrientation($value)
582584
{
583-
$this->_orientation = floatval($value) - floor(floatval($value) / 360) * 360;
585+
$value = floatval($value);
586+
$this->_orientation = $value - floor($value / 360) * 360;
584587
return $this;
585588
}
586589

@@ -812,10 +815,12 @@ public function setFont($value)
812815
$this->_font = $value;
813816
} else {
814817
require_once 'Zend/Barcode/Object/Exception.php';
815-
throw new Zend_Barcode_Object_Exception(sprintf(
816-
'Invalid font "%s" provided to setFont()',
817-
$value
818-
));
818+
throw new Zend_Barcode_Object_Exception(
819+
sprintf(
820+
'Invalid font "%s" provided to setFont()',
821+
$value
822+
)
823+
);
819824
}
820825
return $this;
821826
}
@@ -912,12 +917,14 @@ protected function _addPolygon(array $points, $color = null, $filled = true)
912917
if ($color === null) {
913918
$color = $this->_foreColor;
914919
}
915-
$this->_addInstruction(array(
916-
'type' => 'polygon',
917-
'points' => $points,
918-
'color' => $color,
919-
'filled' => $filled,
920-
));
920+
$this->_addInstruction(
921+
array(
922+
'type' => 'polygon',
923+
'points' => $points,
924+
'color' => $color,
925+
'filled' => $filled,
926+
)
927+
);
921928
}
922929

923930
/**
@@ -943,16 +950,18 @@ protected function _addText(
943950
if ($color === null) {
944951
$color = $this->_foreColor;
945952
}
946-
$this->_addInstruction(array(
947-
'type' => 'text',
948-
'text' => $text,
949-
'size' => $size,
950-
'position' => $position,
951-
'font' => $font,
952-
'color' => $color,
953-
'alignment' => $alignment,
954-
'orientation' => $orientation,
955-
));
953+
$this->_addInstruction(
954+
array(
955+
'type' => 'text',
956+
'text' => $text,
957+
'size' => $size,
958+
'position' => $position,
959+
'font' => $font,
960+
'color' => $color,
961+
'alignment' => $alignment,
962+
'orientation' => $orientation,
963+
)
964+
);
956965
}
957966

958967
/**
@@ -1000,12 +1009,14 @@ protected function _checkRatio($min = 2, $max = 3)
10001009
$ratio = $this->_barThickWidth / $this->_barThinWidth;
10011010
if (!($ratio >= $min && $ratio <= $max)) {
10021011
require_once 'Zend/Barcode/Object/Exception.php';
1003-
throw new Zend_Barcode_Object_Exception(sprintf(
1004-
'Ratio thick/thin bar must be between %0.1f and %0.1f (actual %0.3f)',
1005-
$min,
1006-
$max,
1007-
$ratio
1008-
));
1012+
throw new Zend_Barcode_Object_Exception(
1013+
sprintf(
1014+
'Ratio thick/thin bar must be between %0.1f and %0.1f (actual %0.3f)',
1015+
$min,
1016+
$max,
1017+
$ratio
1018+
)
1019+
);
10091020
}
10101021
}
10111022

@@ -1068,7 +1079,9 @@ protected function _calculateBarcodeHeight()
10681079
$textHeight += $this->_fontSize;
10691080
$extraHeight = 2;
10701081
}
1071-
return ($this->_barHeight + $textHeight) * $this->_factor + $extraHeight;
1082+
1083+
return ($this->_barHeight + $textHeight) * $this->_factor
1084+
+ $extraHeight;
10721085
}
10731086

10741087
/**
@@ -1081,8 +1094,16 @@ public function getHeight($recalculate = false)
10811094
{
10821095
if ($this->_height === null || $recalculate) {
10831096
$this->_height =
1084-
abs($this->_calculateHeight() * cos($this->_orientation / 180 * pi()))
1085-
+ abs($this->_calculateWidth() * sin($this->_orientation / 180 * pi()));
1097+
abs(
1098+
$this->_calculateHeight() * cos(
1099+
$this->_orientation / 180 * pi()
1100+
)
1101+
)
1102+
+ abs(
1103+
$this->_calculateWidth() * sin(
1104+
$this->_orientation / 180 * pi()
1105+
)
1106+
);
10861107
}
10871108
return $this->_height;
10881109
}
@@ -1097,8 +1118,16 @@ public function getWidth($recalculate = false)
10971118
{
10981119
if ($this->_width === null || $recalculate) {
10991120
$this->_width =
1100-
abs($this->_calculateWidth() * cos($this->_orientation / 180 * pi()))
1101-
+ abs($this->_calculateHeight() * sin($this->_orientation / 180 * pi()));
1121+
abs(
1122+
$this->_calculateWidth() * cos(
1123+
$this->_orientation / 180 * pi()
1124+
)
1125+
)
1126+
+ abs(
1127+
$this->_calculateHeight() * sin(
1128+
$this->_orientation / 180 * pi()
1129+
)
1130+
);
11021131
}
11031132
return $this->_width;
11041133
}
@@ -1174,7 +1203,11 @@ protected function _rotate($x1, $y1)
11741203
$y2 = $y1 * cos($this->_orientation / 180 * pi())
11751204
+ $x1 * sin($this->_orientation / 180 * pi())
11761205
+ $this->getOffsetTop();
1177-
return array(intval($x2) , intval($y2));
1206+
1207+
return array(
1208+
intval($x2),
1209+
intval($y2)
1210+
);
11781211
}
11791212

11801213
/**
@@ -1211,12 +1244,14 @@ protected function _drawBarcode()
12111244
);
12121245
$point4 = $this->_rotate($this->_calculateWidth() - 1, 0);
12131246

1214-
$this->_addPolygon(array(
1215-
$point1,
1216-
$point2,
1217-
$point3,
1218-
$point4
1219-
), $this->_backgroundColor);
1247+
$this->_addPolygon(
1248+
array(
1249+
$point1,
1250+
$point2,
1251+
$point3,
1252+
$point4
1253+
), $this->_backgroundColor
1254+
);
12201255

12211256
$xpos += $this->getQuietZone();
12221257
$barLength = $this->_barHeight * $this->_factor;
@@ -1234,12 +1269,14 @@ protected function _drawBarcode()
12341269
$xpos + $width - 1,
12351270
$ypos + $bar[2] * $barLength
12361271
);
1237-
$this->_addPolygon(array(
1238-
$point1,
1239-
$point2,
1240-
$point3,
1241-
$point4,
1242-
));
1272+
$this->_addPolygon(
1273+
array(
1274+
$point1,
1275+
$point2,
1276+
$point3,
1277+
$point4,
1278+
)
1279+
);
12431280
}
12441281
$xpos += $width;
12451282
}
@@ -1260,13 +1297,15 @@ protected function _drawBorder()
12601297
$this->_calculateHeight() - 1
12611298
);
12621299
$point4 = $this->_rotate(0, $this->_calculateHeight() - 1);
1263-
$this->_addPolygon(array(
1264-
$point1,
1265-
$point2,
1266-
$point3,
1267-
$point4,
1268-
$point1,
1269-
), $this->_foreColor, false);
1300+
$this->_addPolygon(
1301+
array(
1302+
$point1,
1303+
$point2,
1304+
$point3,
1305+
$point4,
1306+
$point1,
1307+
), $this->_foreColor, false
1308+
);
12701309
}
12711310
}
12721311

@@ -1335,10 +1374,12 @@ protected function _validateText($value, $options = array())
13351374
{
13361375
$validatorName = (isset($options['validator'])) ? $options['validator'] : $this->getType();
13371376

1338-
$validator = new Zend_Validate_Barcode(array(
1339-
'adapter' => $validatorName,
1340-
'checksum' => false,
1341-
));
1377+
$validator = new Zend_Validate_Barcode(
1378+
array(
1379+
'adapter' => $validatorName,
1380+
'checksum' => false,
1381+
)
1382+
);
13421383

13431384
$checksumCharacter = '';
13441385
$withChecksum = false;
@@ -1347,7 +1388,8 @@ protected function _validateText($value, $options = array())
13471388
$withChecksum = true;
13481389
}
13491390

1350-
$value = $this->_addLeadingZeros($value, $withChecksum) . $checksumCharacter;
1391+
$value = $this->_addLeadingZeros($value, $withChecksum)
1392+
. $checksumCharacter;
13511393

13521394
if (!$validator->isValid($value)) {
13531395
$message = implode("\n", $validator->getMessages());

0 commit comments

Comments
 (0)