C128CObject::C128CObject()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 118

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 118
rs 8
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
//============================================================+
3
// File name   : c128cobject.php
4
// Begin       : 2002-07-31
5
// Last Update : 2004-12-29
6
// Author      : Karim Mribti [[email protected]]
7
//             : Sam Michaels [[email protected]]
8
//             : Nicola Asuni [[email protected]]
9
// Version     : 0.0.8a  2001-04-01 (original code)
10
// License     : GNU LGPL (Lesser General Public License) 2.1
11
//               http://www.gnu.org/copyleft/lesser.txt
12
// Source Code : http://www.mribti.com/barcode/
13
//
14
// Description : Code 128-C Barcode Render Class for PHP using
15
//               the GD graphics library.
16
//               Code 128-C is numeric only and provides the
17
//               most efficiency.
18
//
19
// NOTE:
20
// This version contains changes by Nicola Asuni:
21
//  - porting to PHP4
22
//  - code style and formatting
23
//  - automatic php documentation in PhpDocumentor Style
24
//    (www.phpdoc.org)
25
//  - minor bug fixing
26
//============================================================+
27
28
/**
29
 * Code 128-C Barcode Render Class for PHP using the GD graphics library.<br>
30
 * Code 128-C is numeric only and provides the most efficiency.
31
 * @author Karim Mribti, Nicola Asuni
32
 * @name BarcodeObject
33
 * @package com.tecnick.tcpdf
34
 * @version 0.0.8a  2001-04-01 (original code)
35
 * @since 2001-03-25
36
 * @license http://www.gnu.org/copyleft/lesser.html LGPL
37
 */
38
39
/**
40
 * Code 128-C Barcode Render Class for PHP using the GD graphics library.<br>
41
 * Code 128-C is numeric only and provides the most efficiency.
42
 * @author Karim Mribti, Nicola Asuni
43
 * @name BarcodeObject
44
 * @package com.tecnick.tcpdf
45
 * @version 0.0.8a  2001-04-01 (original code)
46
 * @since 2001-03-25
47
 * @license http://www.gnu.org/copyleft/lesser.html LGPL
48
 */
49
class C128CObject extends BarcodeObject {
50
	
51
	/**
52
	 * Class Constructor.
53
	 * @param int $Width Image width in pixels.
54
	 * @param int $Height Image height in pixels. 
55
	 * @param int $Style Barcode style.
56
	 * @param int $Value value to print on barcode.
57
	 */
58
	function C128CObject($Width, $Height, $Style, $Value) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
59
		$this->BarcodeObject($Width, $Height, $Style);
60
		$this->mValue = $Value;
0 ignored issues
show
Bug introduced by
The property mValue does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
61
		$this->mChars = array (
0 ignored issues
show
Documentation Bug introduced by
It seems like array('00', '01', '02', ...'96', '97', '98', '99') of type array<integer,string,{"0...string","99":"string"}> is incompatible with the declared type object<Allowed> of property $mChars.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
62
		"00", "01", "02", "03", "04", "05", "06", "07", "08", "09",
63
		"10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
64
		"20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
65
		"30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
66
		"40", "41", "42", "43", "44", "45", "46", "47", "48", "49",
67
		"50", "51", "52", "53", "54", "55", "56", "57", "58", "59",
68
		"60", "61", "62", "63", "64", "65", "66", "67", "68", "69",
69
		"70", "71", "72", "73", "74", "75", "76", "77", "78", "79",
70
		"80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
71
		"90", "91", "92", "93", "94", "95", "96", "97", "98", "99",
72
		);
73
		$this->mCharSet = array (
0 ignored issues
show
Documentation Bug introduced by
It seems like array('212222', '222122'...3', '411311', '113141') of type array<integer,string,{"0...string","99":"string"}> is incompatible with the declared type object<Character> of property $mCharSet.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
74
		"212222",   /*   00 */
75
		"222122",   /*   01 */
76
		"222221",   /*   02 */
77
		"121223",   /*   03 */
78
		"121322",   /*   04 */
79
		"131222",   /*   05 */
80
		"122213",   /*   06 */
81
		"122312",   /*   07 */
82
		"132212",   /*   08 */
83
		"221213",   /*   09 */
84
		"221312",   /*   10 */
85
		"231212",   /*   11 */
86
		"112232",   /*   12 */
87
		"122132",   /*   13 */
88
		"122231",   /*   14 */
89
		"113222",   /*   15 */
90
		"123122",   /*   16 */
91
		"123221",   /*   17 */
92
		"223211",   /*   18 */
93
		"221132",   /*   19 */
94
		"221231",   /*   20 */
95
		"213212",   /*   21 */
96
		"223112",   /*   22 */
97
		"312131",   /*   23 */
98
		"311222",   /*   24 */
99
		"321122",   /*   25 */
100
		"321221",   /*   26 */
101
		"312212",   /*   27 */
102
		"322112",   /*   28 */
103
		"322211",   /*   29 */
104
		"212123",   /*   30 */
105
		"212321",   /*   31 */
106
		"232121",   /*   32 */
107
		"111323",   /*   33 */
108
		"131123",   /*   34 */
109
		"131321",   /*   35 */
110
		"112313",   /*   36 */
111
		"132113",   /*   37 */
112
		"132311",   /*   38 */
113
		"211313",   /*   39 */
114
		"231113",   /*   40 */
115
		"231311",   /*   41 */
116
		"112133",   /*   42 */
117
		"112331",   /*   43 */
118
		"132131",   /*   44 */
119
		"113123",   /*   45 */
120
		"113321",   /*   46 */
121
		"133121",   /*   47 */
122
		"313121",   /*   48 */
123
		"211331",   /*   49 */
124
		"231131",   /*   50 */
125
		"213113",   /*   51 */
126
		"213311",   /*   52 */
127
		"213131",   /*   53 */
128
		"311123",   /*   54 */
129
		"311321",   /*   55 */
130
		"331121",   /*   56 */
131
		"312113",   /*   57 */
132
		"312311",   /*   58 */
133
		"332111",   /*   59 */
134
		"314111",   /*   60 */
135
		"221411",   /*   61 */
136
		"431111",   /*   62 */
137
		"111224",   /*   63 */
138
		"111422",   /*   64 */
139
		"121124",   /*   65 */
140
		"121421",   /*   66 */
141
		"141122",   /*   67 */
142
		"141221",   /*   68 */
143
		"112214",   /*   69 */
144
		"112412",   /*   70 */
145
		"122114",   /*   71 */
146
		"122411",   /*   72 */
147
		"142112",   /*   73 */
148
		"142211",   /*   74 */
149
		"241211",   /*   75 */
150
		"221114",   /*   76 */
151
		"413111",   /*   77 */
152
		"241112",   /*   78 */
153
		"134111",   /*   79 */
154
		"111242",   /*   80 */
155
		"121142",   /*   81 */
156
		"121241",   /*   82 */
157
		"114212",   /*   83 */
158
		"124112",   /*   84 */
159
		"124211",   /*   85 */
160
		"411212",   /*   86 */
161
		"421112",   /*   87 */
162
		"421211",   /*   88 */
163
		"212141",   /*   89 */
164
		"214121",   /*   90 */
165
		"412121",   /*   91 */
166
		"111143",   /*   92 */
167
		"111341",   /*   93 */
168
		"131141",   /*   94 */
169
		"114113",   /*   95 */
170
		"114311",   /*   96 */
171
		"411113",   /*   97 */
172
		"411311",   /*   98 */
173
		"113141",   /*   99 */
174
		);
175
	}
176
177
	/**
178
	 * Returns the character index.
179
	 * @param char $char character.
180
	 * @return int character index or -1 in case of error.
181
	 * @access private
182
	 */
183
	function GetCharIndex($char) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
184
		for ($i=0;$i<100;$i++) {
185
			if ($this->mChars[$i] == $char) {
186
				return $i;
187
			}
188
		}
189
		return -1;
190
	}
191
	
192
	/**
193
	 * Returns the bar size.
194
	 * @param int $xres Horizontal resolution.
195
	 * @param char $char Character.
196
	 * @return int barcode size.
197
	 * @access private
198
	 */
199
	function GetBarSize($xres, $char) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
200
		switch ($char) {
201
			case '1': {
202
				$cVal = BCD_C128_BAR_1;
203
				break;
204
			}
205
			case '2': {
206
				$cVal = BCD_C128_BAR_2;
207
				break;
208
			}
209
			case '3': {
210
				$cVal = BCD_C128_BAR_3;
211
				break;
212
			}
213
			case '4': {
214
				$cVal = BCD_C128_BAR_4;
215
				break;
216
			}
217
			default: {
218
				$cVal = 0;
219
			}
220
		}
221
		return  $cVal * $xres;
222
	}
223
224
	/**
225
	 * Returns barcode size.
226
	 * @param int $xres Horizontal resolution.
227
	 * @return barcode size.
0 ignored issues
show
Documentation introduced by
Should the return type not be false|integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
228
	 * @access private
229
	 */
230
	function GetSize($xres) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
231
		$len = strlen($this->mValue);
232
233
		if ($len == 0)  {
234
			$this->mError = "Null value";
0 ignored issues
show
Documentation Bug introduced by
It seems like 'Null value' of type string is incompatible with the declared type object<Error> of property $mError.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
235
			return false;
236
		}
237
		$ret = 0;
238
239 View Code Duplication
		for ($i=0;$i<$len;$i++) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
240
			if ((ord($this->mValue[$i])<48) || (ord($this->mValue[$i])>57)) {
241
				$this->mError = "Code-128C is numeric only";
0 ignored issues
show
Documentation Bug introduced by
It seems like 'Code-128C is numeric only' of type string is incompatible with the declared type object<Error> of property $mError.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
242
				return false;
243
			}
244
		}
245
246
		if (($len%2) != 0) {
247
			$this->mError = "The length of barcode value must be even.  You must pad the number with zeros.";
0 ignored issues
show
Documentation Bug introduced by
It seems like 'The length of barcode v...the number with zeros.' of type string is incompatible with the declared type object<Error> of property $mError.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
248
			return false;
249
		}
250
251
		for ($i=0;$i<$len;$i+=2) {
252
			$id = $this->GetCharIndex($this->mValue[$i].$this->mValue[$i+1]);
0 ignored issues
show
Documentation introduced by
$this->mValue[$i] . $this->mValue[$i + 1] is of type string, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
253
			$cset = $this->mCharSet[$id];
254
			$ret += $this->GetBarSize($xres, $cset[0]);
255
			$ret += $this->GetBarSize($xres, $cset[1]);
256
			$ret += $this->GetBarSize($xres, $cset[2]);
257
			$ret += $this->GetBarSize($xres, $cset[3]);
258
			$ret += $this->GetBarSize($xres, $cset[4]);
259
			$ret += $this->GetBarSize($xres, $cset[5]);
260
		}
261
		/* length of Check character */
262
		$cset = $this->GetCheckCharValue();
263
		$CheckSize = 0;
264
		for ($i=0;$i<6;$i++) {
265
			$CheckSize += $this->GetBarSize($cset[$i], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
266
		}
267
268
		$StartSize = 2*BCD_C128_BAR_2*$xres + 3*BCD_C128_BAR_1*$xres + BCD_C128_BAR_4*$xres;
269
		$StopSize  = 2*BCD_C128_BAR_2*$xres + 3*BCD_C128_BAR_1*$xres + 2*BCD_C128_BAR_3*$xres;
270
		return $StartSize + $ret + $CheckSize + $StopSize;
271
	}
272
	
273
	/**
274
	 * Returns the check-char value.
275
	 * @return string.
0 ignored issues
show
Documentation introduced by
The doc-type string. could not be parsed: Unknown type name "string." at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
276
	 * @access private
277
	 */
278
	function GetCheckCharValue() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
279
		$len = strlen($this->mValue);
280
		$sum = 105; // 'C' type;
281
		$m = 0;
282
		for ($i=0;$i<$len;$i+=2) {
283
			$m++;
284
			$sum +=  $this->GetCharIndex($this->mValue[$i].$this->mValue[$i+1]) * $m;
0 ignored issues
show
Documentation introduced by
$this->mValue[$i] . $this->mValue[$i + 1] is of type string, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
285
		}
286
		$check  = $sum % 103;
287
		return $this->mCharSet[$check];
288
	}
289
290
	/**
291
	 * Draws the start code.
292
	 * @param int $DrawPos Drawing position.
293
	 * @param int $yPos Vertical position.
294
	 * @param int $ySize Vertical size.
295
	 * @param int $xres Horizontal resolution.
296
	 * @return int drawing position.
297
	 * @access private
298
	 */
299
	function DrawStart($DrawPos, $yPos, $ySize, $xres) {
0 ignored issues
show
Unused Code introduced by
The parameter $yPos is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
300
		/* Start code is '211232' */
301
		$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('2', $xres) , $ySize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
302
		$DrawPos += $this->GetBarSize('2', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
303
		$DrawPos += $this->GetBarSize('1', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
304
		$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('1', $xres) , $ySize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
305
		$DrawPos += $this->GetBarSize('1', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
306
		$DrawPos += $this->GetBarSize('2', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
307
		$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('3', $xres) , $ySize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
308
		$DrawPos += $this->GetBarSize('3', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
309
		$DrawPos += $this->GetBarSize('2', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
310
		return $DrawPos;
311
	}
312
	
313
	/**
314
	 * Draws the stop code.
315
	 * @param int $DrawPos Drawing position.
316
	 * @param int $yPos Vertical position.
317
	 * @param int $ySize Vertical size.
318
	 * @param int $xres Horizontal resolution.
319
	 * @return int drawing position.
320
	 * @access private
321
	 */
322
	function DrawStop($DrawPos, $yPos, $ySize, $xres) {
0 ignored issues
show
Unused Code introduced by
The parameter $yPos is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
323
		/* Stop code is '2331112' */
324
		$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('2', $xres) , $ySize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
325
		$DrawPos += $this->GetBarSize('2', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
326
		$DrawPos += $this->GetBarSize('3', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
327
		$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('3', $xres) , $ySize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
328
		$DrawPos += $this->GetBarSize('3', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
329
		$DrawPos += $this->GetBarSize('1', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
330
		$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('1', $xres) , $ySize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
331
		$DrawPos += $this->GetBarSize('1', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
332
		$DrawPos += $this->GetBarSize('1', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
333
		$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize('2', $xres) , $ySize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
334
		$DrawPos += $this->GetBarSize('2', $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
335
		return $DrawPos;
336
	}
337
	
338
	/**
339
	 * Draws the check-char code.
340
	 * @param int $DrawPos Drawing position.
341
	 * @param int $yPos Vertical position.
342
	 * @param int $ySize Vertical size.
343
	 * @param int $xres Horizontal resolution.
344
	 * @return int drawing position.
345
	 * @access private
346
	 */
347
	function DrawCheckChar($DrawPos, $yPos, $ySize, $xres) {
0 ignored issues
show
Unused Code introduced by
The parameter $yPos is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
348
		$cset = $this->GetCheckCharValue();
349
		$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[0], $xres) , $ySize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
350
		$DrawPos += $this->GetBarSize($cset[0], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
351
		$DrawPos += $this->GetBarSize($cset[1], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
352
		$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[2], $xres) , $ySize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
353
		$DrawPos += $this->GetBarSize($cset[2], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
354
		$DrawPos += $this->GetBarSize($cset[3], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
355
		$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[4], $xres) , $ySize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
356
		$DrawPos += $this->GetBarSize($cset[4], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
357
		$DrawPos += $this->GetBarSize($cset[5], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
358
		return $DrawPos;
359
	}
360
361
	/**
362
	 * Draws the barcode object.
363
	 * @param int $xres Horizontal resolution.
364
	 * @return bool true in case of success.
365
	 */
366
	function DrawObject($xres) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
367
		$len = strlen($this->mValue);
368
		if (($size = $this->GetSize($xres))==0) {
369
			return false;
370
		}
371
372
		if ($this->mStyle & BCS_ALIGN_CENTER) $sPos = (integer)(($this->mWidth - $size ) / 2);
373
		else if ($this->mStyle & BCS_ALIGN_RIGHT) $sPos = $this->mWidth - $size;
374
		else $sPos = 0;
375
376
		/* Total height of bar code -Bars only- */
377
		if ($this->mStyle & BCS_DRAW_TEXT) $ysize = $this->mHeight - BCD_DEFAULT_MAR_Y1 - BCD_DEFAULT_MAR_Y2 - $this->GetFontHeight($this->mFont);
378
		else $ysize = $this->mHeight - BCD_DEFAULT_MAR_Y1 - BCD_DEFAULT_MAR_Y2;
379
380
		/* Draw text */
381
		if ($this->mStyle & BCS_DRAW_TEXT) {
382
			if ($this->mStyle & BCS_STRETCH_TEXT) {
383
				for ($i=0;$i<$len;$i++) {
384
					$this->DrawChar($this->mFont, $sPos+(2*BCD_C128_BAR_2*$xres + 3*BCD_C128_BAR_1*$xres + BCD_C128_BAR_4*$xres)+($size/$len)*$i,
385
					$ysize + BCD_DEFAULT_MAR_Y1 + BCD_DEFAULT_TEXT_OFFSET, $this->mValue[$i]);
386
				}
387
			} else {/* Center */
388
			$text_width = $this->GetFontWidth($this->mFont) * strlen($this->mValue);
389
			$this->DrawText($this->mFont, $sPos+(($size-$text_width)/2)+(2*BCD_C128_BAR_2*$xres + 3*BCD_C128_BAR_1*$xres + BCD_C128_BAR_4*$xres),
390
			$ysize + BCD_DEFAULT_MAR_Y1 + BCD_DEFAULT_TEXT_OFFSET, $this->mValue);
391
			}
392
		}
393
394
		$cPos = 0;
395
		$DrawPos = $this->DrawStart($sPos, BCD_DEFAULT_MAR_Y1 , $ysize, $xres);
396
		do {
397
			$c     = $this->GetCharIndex($this->mValue[$cPos].$this->mValue[$cPos+1]);
0 ignored issues
show
Documentation introduced by
$this->mValue[$cPos] . $this->mValue[$cPos + 1] is of type string, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
398
			$cset  = $this->mCharSet[$c];
399
			$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[0], $xres) , $ysize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
400
			$DrawPos += $this->GetBarSize($cset[0], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
401
			$DrawPos += $this->GetBarSize($cset[1], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
402
			$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[2], $xres) , $ysize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
403
			$DrawPos += $this->GetBarSize($cset[2], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
404
			$DrawPos += $this->GetBarSize($cset[3], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
405
			$this->DrawSingleBar($DrawPos, BCD_DEFAULT_MAR_Y1, $this->GetBarSize($cset[4], $xres) , $ysize);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
406
			$DrawPos += $this->GetBarSize($cset[4], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
407
			$DrawPos += $this->GetBarSize($cset[5], $xres);
0 ignored issues
show
Documentation introduced by
$xres is of type integer, but the function expects a object<char>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
408
			$cPos += 2;
409
		} while ($cPos<$len);
410
		$DrawPos = $this->DrawCheckChar($DrawPos, BCD_DEFAULT_MAR_Y1 , $ysize, $xres);
411
		$DrawPos =  $this->DrawStop($DrawPos, BCD_DEFAULT_MAR_Y1 , $ysize, $xres);
0 ignored issues
show
Unused Code introduced by
$DrawPos is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
412
		return true;
413
	}
414
}
415
416
//============================================================+
417
// END OF FILE
418
//============================================================+
419
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
420