1 | <?php |
||
14 | final class Parser implements ParserInterface |
||
15 | { |
||
16 | private const ENCODABLE_VALUE_CHARACTERS_SET = [ |
||
17 | '!', |
||
18 | '"', |
||
19 | '%', |
||
20 | '&', |
||
21 | '\'', |
||
22 | '(', |
||
23 | ')', |
||
24 | '*', |
||
25 | '+', |
||
26 | ',', |
||
27 | '-', |
||
28 | '_', |
||
29 | '.', |
||
30 | '/', |
||
31 | '0', |
||
32 | '1', |
||
33 | '2', |
||
34 | '3', |
||
35 | '4', |
||
36 | '5', |
||
37 | '6', |
||
38 | '7', |
||
39 | '8', |
||
40 | '9', |
||
41 | ':', |
||
42 | ';', |
||
43 | '<', |
||
44 | '=', |
||
45 | '>', |
||
46 | '?', |
||
47 | 'A', |
||
48 | 'B', |
||
49 | 'C', |
||
50 | 'D', |
||
51 | 'E', |
||
52 | 'F', |
||
53 | 'G', |
||
54 | 'H', |
||
55 | 'I', |
||
56 | 'J', |
||
57 | 'K', |
||
58 | 'L', |
||
59 | 'M', |
||
60 | 'N', |
||
61 | 'O', |
||
62 | 'P', |
||
63 | 'Q', |
||
64 | 'R', |
||
65 | 'S', |
||
66 | 'T', |
||
67 | 'U', |
||
68 | 'V', |
||
69 | 'W', |
||
70 | 'X', |
||
71 | 'Y', |
||
72 | 'Z', |
||
73 | 'a', |
||
74 | 'b', |
||
75 | 'c', |
||
76 | 'd', |
||
77 | 'e', |
||
78 | 'f', |
||
79 | 'g', |
||
80 | 'h', |
||
81 | 'i', |
||
82 | 'j', |
||
83 | 'k', |
||
84 | 'l', |
||
85 | 'm', |
||
86 | 'n', |
||
87 | 'o', |
||
88 | 'p', |
||
89 | 'q', |
||
90 | 'r', |
||
91 | 's', |
||
92 | 't', |
||
93 | 'u', |
||
94 | 'v', |
||
95 | 'w', |
||
96 | 'x', |
||
97 | 'y', |
||
98 | 'z', |
||
99 | ]; |
||
100 | private const FIXED_LENGTH_AIS = [ |
||
101 | '00' => 20, |
||
102 | '01' => 16, |
||
103 | '02' => 16, |
||
104 | '03' => 16, |
||
105 | '04' => 18, |
||
106 | '11' => 8, |
||
107 | '12' => 8, |
||
108 | '13' => 8, |
||
109 | '14' => 8, |
||
110 | '15' => 8, |
||
111 | '16' => 8, |
||
112 | '17' => 8, |
||
113 | '18' => 8, |
||
114 | '19' => 8, |
||
115 | '20' => 4, |
||
116 | '31' => 10, |
||
117 | '32' => 10, |
||
118 | '33' => 10, |
||
119 | '34' => 10, |
||
120 | '35' => 10, |
||
121 | '36' => 10, |
||
122 | '41' => 16, |
||
123 | ]; |
||
124 | private const FIXED_AI_LENGTH = 2; |
||
125 | |||
126 | /** |
||
127 | * @var ParserConfig |
||
128 | */ |
||
129 | private $config; |
||
130 | |||
131 | 12 | public function __construct(ParserConfig $config) |
|
135 | |||
136 | 12 | public function parse(string $data): Barcode |
|
217 | |||
218 | 12 | private function fetchFNC1Prefix(string $data): array |
|
228 | |||
229 | 12 | private function fetchFixedAI(string $data, int $position, int $dataLength): array |
|
245 | |||
246 | 12 | private function fetchKnownAI(string $data, int $position): array |
|
257 | |||
258 | 12 | private function assertValueIsValid(string $value): void |
|
266 | } |
||
267 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
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.