C128AObject   A
last analyzed

Complexity

Total Complexity 28

Size/Duplication

Total Lines 347
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 347
loc 347
rs 10
c 0
b 0
f 0
wmc 28
lcom 1
cbo 1

9 Methods

Rating   Name   Duplication   Size   Complexity  
B C128AObject() 110 110 1
A GetCharIndex() 8 8 3
A GetBarSize() 24 24 5
A GetSize() 33 33 5
A GetCheckCharValue() 9 9 2
A DrawStart() 13 13 1
A DrawStop() 15 15 1
A DrawCheckChar() 13 13 1
B DrawObject() 48 48 9

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
//============================================================+
3
// File name   : c128aobject.php
4
// Begin       : 2002-07-31
5
// Last Update : 2004-12-29
6
// Author      : Karim Mribti [[email protected]]
7
// Version     : 0.0.8a  2001-04-01 (original code)
8
// License     : GNU LGPL (Lesser General Public License) 2.1
9
//               http://www.gnu.org/copyleft/lesser.txt
10
// Source Code : http://www.mribti.com/barcode/
11
//
12
// Description : Code 128-A Barcode Render Class for PHP using
13
//               the GD graphics library.
14
//               Code 128-A is a continuous, multilevel and
15
//               include all upper case alphanumeric characters
16
//               and ASCII control characters.
17
//
18
// NOTE:
19
// This version contains changes by Nicola Asuni:
20
//  - porting to PHP4
21
//  - code style and formatting
22
//  - automatic php documentation in PhpDocumentor Style
23
//    (www.phpdoc.org)
24
//  - minor bug fixing
25
//============================================================+
26
27
/**
28
 * Code 128-A Barcode Render Class for PHP using the GD graphics library.<br>
29
 * Code 128-A is a continuous, multilevel and include all upper case alphanumeric characters and ASCII control characters.
30
 * @author Karim Mribti, Nicola Asuni
31
 * @name BarcodeObject
32
 * @package com.tecnick.tcpdf
33
 * @version 0.0.8a  2001-04-01 (original code)
34
 * @since 2001-03-25
35
 * @license http://www.gnu.org/copyleft/lesser.html LGPL
36
 */
37
38
/**
39
 * Code 128-A Barcode Render Class for PHP using the GD graphics library.<br>
40
 * Code 128-A is a continuous, multilevel and include all upper case alphanumeric characters and ASCII control characters.
41
 * @author Karim Mribti, Nicola Asuni
42
 * @name BarcodeObject
43
 * @package com.tecnick.tcpdf
44
 * @version 0.0.8a  2001-04-01 (original code)
45
 * @since 2001-03-25
46
 * @license http://www.gnu.org/copyleft/lesser.html LGPL
47
 */
48 View Code Duplication
class C128AObject extends BarcodeObject {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
49
	
50
	/**
51
	 * Class Constructor.
52
	 * @param int $Width Image width in pixels.
53
	 * @param int $Height Image height in pixels. 
54
	 * @param int $Style Barcode style.
55
	 * @param int $Value value to print on barcode.
56
	 */
57
	function C128AObject($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...
58
		$this->BarcodeObject($Width, $Height, $Style);
59
		$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...
60
		$this->mChars   = " !\"#$%&'()*+�-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
0 ignored issues
show
Documentation Bug introduced by
It seems like ' !"#$%&\'()*+�-./0123...KLMNOPQRSTUVWXYZ[\\]^_' of type 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...
61
		$this->mCharSet = array (
0 ignored issues
show
Documentation Bug introduced by
It seems like array('212222', '222122'...1', '311141', '411131') of type array<integer,string,{"0...tring","102":"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...
62
		"212222",   /*   00 */
63
		"222122",   /*   01 */
64
		"222221",   /*   02 */
65
		"121223",   /*   03 */
66
		"121322",   /*   04 */
67
		"131222",   /*   05 */
68
		"122213",   /*   06 */
69
		"122312",   /*   07 */
70
		"132212",   /*   08 */
71
		"221213",   /*   09 */
72
		"221312",   /*   10 */
73
		"231212",   /*   11 */
74
		"112232",   /*   12 */
75
		"122132",   /*   13 */
76
		"122231",   /*   14 */
77
		"113222",   /*   15 */
78
		"123122",   /*   16 */
79
		"123221",   /*   17 */
80
		"223211",   /*   18 */
81
		"221132",   /*   19 */
82
		"221231",   /*   20 */
83
		"213212",   /*   21 */
84
		"223112",   /*   22 */
85
		"312131",   /*   23 */
86
		"311222",   /*   24 */
87
		"321122",   /*   25 */
88
		"321221",   /*   26 */
89
		"312212",   /*   27 */
90
		"322112",   /*   28 */
91
		"322211",   /*   29 */
92
		"212123",   /*   30 */
93
		"212321",   /*   31 */
94
		"232121",   /*   32 */
95
		"111323",   /*   33 */
96
		"131123",   /*   34 */
97
		"131321",   /*   35 */
98
		"112313",   /*   36 */
99
		"132113",   /*   37 */
100
		"132311",   /*   38 */
101
		"211313",   /*   39 */
102
		"231113",   /*   40 */
103
		"231311",   /*   41 */
104
		"112133",   /*   42 */
105
		"112331",   /*   43 */
106
		"132131",   /*   44 */
107
		"113123",   /*   45 */
108
		"113321",   /*   46 */
109
		"133121",   /*   47 */
110
		"313121",   /*   48 */
111
		"211331",   /*   49 */
112
		"231131",   /*   50 */
113
		"213113",   /*   51 */
114
		"213311",   /*   52 */
115
		"213131",   /*   53 */
116
		"311123",   /*   54 */
117
		"311321",   /*   55 */
118
		"331121",   /*   56 */
119
		"312113",   /*   57 */
120
		"312311",   /*   58 */
121
		"332111",   /*   59 */
122
		"314111",   /*   60 */
123
		"221411",   /*   61 */
124
		"431111",   /*   62 */
125
		"111224",   /*   63 */
126
		"111422",   /*   64 */
127
		"121124",   /*   65 */
128
		"121421",   /*   66 */
129
		"141122",   /*   67 */
130
		"141221",   /*   68 */
131
		"112214",   /*   69 */
132
		"112412",   /*   70 */
133
		"122114",   /*   71 */
134
		"122411",   /*   72 */
135
		"142112",   /*   73 */
136
		"142211",   /*   74 */
137
		"241211",   /*   75 */
138
		"221114",   /*   76 */
139
		"413111",   /*   77 */
140
		"241112",   /*   78 */
141
		"134111",   /*   79 */
142
		"111242",   /*   80 */
143
		"121142",   /*   81 */
144
		"121241",   /*   82 */
145
		"114212",   /*   83 */
146
		"124112",   /*   84 */
147
		"124211",   /*   85 */
148
		"411212",   /*   86 */
149
		"421112",   /*   87 */
150
		"421211",   /*   88 */
151
		"212141",   /*   89 */
152
		"214121",   /*   90 */
153
		"412121",   /*   91 */
154
		"111143",   /*   92 */
155
		"111341",   /*   93 */
156
		"131141",   /*   94 */
157
		"114113",   /*   95 */
158
		"114311",   /*   96 */
159
		"411113",   /*   97 */
160
		"411311",   /*   98 */
161
		"113141",   /*   99 */
162
		"114131",   /*  100 */
163
		"311141",   /*  101 */
164
		"411131"    /*  102 */
165
		);
166
	}
167
168
	/**
169
	 * Returns the character index.
170
	 * @param char $char character.
171
	 * @return int character index or -1 in case of error.
172
	 * @access private
173
	 */
174
	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...
175
		for ($i=0;$i<64;$i++) {
176
			if ($this->mChars[$i] == $char) {
177
				return $i;
178
			}
179
		}
180
		return -1;
181
	}
182
	
183
	/**
184
	 * Returns the bar size.
185
	 * @param int $xres Horizontal resolution.
186
	 * @param char $char Character.
187
	 * @return int barcode size.
188
	 * @access private
189
	 */
190
	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...
191
		switch ($char) {
192
			case '1': {
193
				$cVal = BCD_C128_BAR_1;
194
				break;
195
			}
196
			case '2': {
197
				$cVal = BCD_C128_BAR_2;
198
				break;
199
			}
200
			case '3': {
201
				$cVal = BCD_C128_BAR_3;
202
				break;
203
			}
204
			case '4': {
205
				$cVal = BCD_C128_BAR_4;
206
				break;
207
			}
208
			default: {
209
				$cVal = 0;
210
			}
211
		}
212
		return  $cVal * $xres;
213
	}
214
	
215
	/**
216
	 * Returns barcode size.
217
	 * @param int $xres Horizontal resolution.
218
	 * @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...
219
	 * @access private
220
	 */
221
	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...
222
		$len = strlen($this->mValue);
223
224
		if ($len == 0)  {
225
			$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...
226
			return false;
227
		}
228
		$ret = 0;
229
		for ($i=0;$i<$len;$i++) {
230
			if (($id = $this->GetCharIndex($this->mValue[$i])) == -1) {
231
				$this->mError = "C128A not include the char '".$this->mValue[$i]."'";
0 ignored issues
show
Documentation Bug introduced by
It seems like 'C128A not include the c...this->mValue[$i] . '\'' 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...
232
				return false;
233
			} else {
234
				$cset = $this->mCharSet[$id];
235
				$ret += $this->GetBarSize($xres, $cset[0]);
236
				$ret += $this->GetBarSize($xres, $cset[1]);
237
				$ret += $this->GetBarSize($xres, $cset[2]);
238
				$ret += $this->GetBarSize($xres, $cset[3]);
239
				$ret += $this->GetBarSize($xres, $cset[4]);
240
				$ret += $this->GetBarSize($xres, $cset[5]);
241
			}
242
		}
243
244
		/* length of Check character */
245
		$cset = $this->GetCheckCharValue();
246
		$CheckSize = 0;
247
		for ($i=0;$i<6;$i++) {
248
			$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...
249
		}
250
		$StartSize = 2*BCD_C128_BAR_2*$xres + 3*BCD_C128_BAR_1*$xres + BCD_C128_BAR_4*$xres;
251
		$StopSize  = 2*BCD_C128_BAR_2*$xres + 3*BCD_C128_BAR_1*$xres + 2*BCD_C128_BAR_3*$xres;
252
		return $StartSize + $ret + $CheckSize + $StopSize;
253
	}
254
	
255
	/**
256
	 * Returns the check-char value.
257
	 * @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...
258
	 * @access private
259
	 */
260
	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...
261
		$len = strlen($this->mValue);
262
		$sum = 103; // 'A' type;
263
		for ($i=0;$i<$len;$i++) {
264
			$sum +=  $this->GetCharIndex($this->mValue[$i]) * ($i+1);
265
		}
266
		$check  = $sum % 103;
267
		return $this->mCharSet[$check];
268
	}
269
270
	/**
271
	 * Draws the start code.
272
	 * @param int $DrawPos Drawing position.
273
	 * @param int $yPos Vertical position.
274
	 * @param int $ySize Vertical size.
275
	 * @param int $xres Horizontal resolution.
276
	 * @return int drawing position.
277
	 * @access private
278
	 */
279
	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...
280
		/* Start code is '211412' */
281
		$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...
282
		$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...
283
		$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...
284
		$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...
285
		$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...
286
		$DrawPos += $this->GetBarSize('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...
287
		$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...
288
		$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...
289
		$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...
290
		return $DrawPos;
291
	}
292
	
293
	/**
294
	 * Draws the stop code.
295
	 * @param int $DrawPos Drawing position.
296
	 * @param int $yPos Vertical position.
297
	 * @param int $ySize Vertical size.
298
	 * @param int $xres Horizontal resolution.
299
	 * @return int drawing position.
300
	 * @access private
301
	 */
302
	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...
303
		/* Stop code is '2331112' */
304
		$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...
305
		$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...
306
		$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...
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('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...
310
		$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...
311
		$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...
312
		$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...
313
		$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...
314
		$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...
315
		return $DrawPos;
316
	}
317
	
318
	/**
319
	 * Draws the check-char code.
320
	 * @param int $DrawPos Drawing position.
321
	 * @param int $yPos Vertical position.
322
	 * @param int $ySize Vertical size.
323
	 * @param int $xres Horizontal resolution.
324
	 * @return int drawing position.
325
	 * @access private
326
	 */
327
	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...
328
		$cset = $this->GetCheckCharValue();
329
		$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...
330
		$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...
331
		$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...
332
		$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...
333
		$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...
334
		$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...
335
		$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...
336
		$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...
337
		$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...
338
		return $DrawPos;
339
	}
340
341
	/**
342
	 * Draws the barcode object.
343
	 * @param int $xres Horizontal resolution.
344
	 * @return bool true in case of success.
345
	 */
346
	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...
347
		$len = strlen($this->mValue);
348
		if (($size = $this->GetSize($xres))==0) {
349
			return false;
350
		}
351
352
		if ($this->mStyle & BCS_ALIGN_CENTER) $sPos = (integer)(($this->mWidth - $size ) / 2);
353
		else if ($this->mStyle & BCS_ALIGN_RIGHT) $sPos = $this->mWidth - $size;
354
		else $sPos = 0;
355
356
		/* Total height of bar code -Bars only- */
357
		if ($this->mStyle & BCS_DRAW_TEXT) $ysize = $this->mHeight - BCD_DEFAULT_MAR_Y1 - BCD_DEFAULT_MAR_Y2 - $this->GetFontHeight($this->mFont);
358
		else $ysize = $this->mHeight - BCD_DEFAULT_MAR_Y1 - BCD_DEFAULT_MAR_Y2;
359
360
		/* Draw text */
361
		if ($this->mStyle & BCS_DRAW_TEXT) {
362
			if ($this->mStyle & BCS_STRETCH_TEXT) {
363
				for ($i=0;$i<$len;$i++) {
364
					$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,
365
					$ysize + BCD_DEFAULT_MAR_Y1 + BCD_DEFAULT_TEXT_OFFSET, $this->mValue[$i]);
366
				}
367
			} else {/* Center */
368
			$text_width = $this->GetFontWidth($this->mFont) * strlen($this->mValue);
369
			$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),
370
			$ysize + BCD_DEFAULT_MAR_Y1 + BCD_DEFAULT_TEXT_OFFSET, $this->mValue);
371
			}
372
		}
373
374
		$cPos = 0;
375
		$DrawPos = $this->DrawStart($sPos, BCD_DEFAULT_MAR_Y1 , $ysize, $xres);
376
		do {
377
			$c     = $this->GetCharIndex($this->mValue[$cPos]);
378
			$cset  = $this->mCharSet[$c];
379
			$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...
380
			$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...
381
			$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...
382
			$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...
383
			$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...
384
			$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...
385
			$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...
386
			$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...
387
			$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...
388
			$cPos++;
389
		} while ($cPos<$len);
390
		$DrawPos = $this->DrawCheckChar($DrawPos, BCD_DEFAULT_MAR_Y1 , $ysize, $xres);
391
		$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...
392
		return true;
393
	}
394
}
395
396
//============================================================+
397
// END OF FILE
398
//============================================================+
399
?>
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...