@@ -77,7 +77,7 @@ public static function decode(
7777 $ fc1InEffect = true ;
7878 } elseif ($ mode == Mode::$ STRUCTURED_APPEND ) {
7979 if ($ bits ->available () < 16 ) {
80- throw FormatException:: getFormatInstance ("Bits available < 16 " );
80+ throw new FormatException ("Bits available < 16 " );
8181 }
8282 // sequence number and parity is added later to the result metadata
8383 // Read next 8 bits (symbol sequence #) and 8 bits (parity data), then continue
@@ -88,7 +88,7 @@ public static function decode(
8888 $ value = self ::parseECIValue ($ bits );
8989 $ currentCharacterSetECI = CharacterSetECI::getCharacterSetECIByValue ($ value );
9090 if ($ currentCharacterSetECI == null ) {
91- throw FormatException:: getFormatInstance ("Current character set ECI is null " );
91+ throw new FormatException ("Current character set ECI is null " );
9292 }
9393 } else {
9494 // First handle Hanzi mode which does not start with character count
@@ -112,15 +112,15 @@ public static function decode(
112112 } elseif ($ mode == Mode::$ KANJI ) {
113113 self ::decodeKanjiSegment ($ bits , $ result , $ count );
114114 } else {
115- throw FormatException:: getFormatInstance ("Unknown mode $ mode to decode " );
115+ throw new FormatException ("Unknown mode $ mode to decode " );
116116 }
117117 }
118118 }
119119 }
120120 } while ($ mode != Mode::$ TERMINATOR );
121121 } catch (\InvalidArgumentException $ e ) {
122122 // from readBits() calls
123- throw FormatException:: getFormatInstance ("Invalid argument exception when formatting: " . $ e ->getMessage ());
123+ throw new FormatException ("Invalid argument exception when formatting: " . $ e ->getMessage ());
124124 }
125125
126126 return new DecoderResult (
@@ -152,7 +152,7 @@ private static function parseECIValue(BitSource $bits): int
152152
153153 return (($ firstByte & 0x1F ) << 16 ) | $ secondThirdBytes ;
154154 }
155- throw FormatException:: getFormatInstance ("ECI Value parsing failed. " );
155+ throw new FormatException ("ECI Value parsing failed. " );
156156 }
157157
158158 /**
@@ -167,7 +167,7 @@ private static function decodeHanziSegment(
167167 ): void {
168168 // Don't crash trying to read more bits than we have available.
169169 if ($ count * 13 > $ bits ->available ()) {
170- throw FormatException:: getFormatInstance ("Trying to read more bits than we have available " );
170+ throw new FormatException ("Trying to read more bits than we have available " );
171171 }
172172
173173 // Each character will require 2 bytes. Read the characters as 2-byte pairs
@@ -202,11 +202,11 @@ private static function decodeNumericSegment(
202202 while ($ count >= 3 ) {
203203 // Each 10 bits encodes three digits
204204 if ($ bits ->available () < 10 ) {
205- throw FormatException:: getFormatInstance ("Not enough bits available " );
205+ throw new FormatException ("Not enough bits available " );
206206 }
207207 $ threeDigitsBits = $ bits ->readBits (10 );
208208 if ($ threeDigitsBits >= 1000 ) {
209- throw FormatException:: getFormatInstance ("Too many three digit bits " );
209+ throw new FormatException ("Too many three digit bits " );
210210 }
211211 $ result .= (self ::toAlphaNumericChar ($ threeDigitsBits / 100 ));
212212 $ result .= (self ::toAlphaNumericChar (($ threeDigitsBits / 10 ) % 10 ));
@@ -216,22 +216,22 @@ private static function decodeNumericSegment(
216216 if ($ count == 2 ) {
217217 // Two digits left over to read, encoded in 7 bits
218218 if ($ bits ->available () < 7 ) {
219- throw FormatException:: getFormatInstance ("Two digits left over to read, encoded in 7 bits, but only " . $ bits ->available () . ' bits available ' );
219+ throw new FormatException ("Two digits left over to read, encoded in 7 bits, but only " . $ bits ->available () . ' bits available ' );
220220 }
221221 $ twoDigitsBits = $ bits ->readBits (7 );
222222 if ($ twoDigitsBits >= 100 ) {
223- throw FormatException:: getFormatInstance ("Too many bits: $ twoDigitsBits expected < 100 " );
223+ throw new FormatException ("Too many bits: $ twoDigitsBits expected < 100 " );
224224 }
225225 $ result .= (self ::toAlphaNumericChar ($ twoDigitsBits / 10 ));
226226 $ result .= (self ::toAlphaNumericChar ($ twoDigitsBits % 10 ));
227227 } elseif ($ count == 1 ) {
228228 // One digit left over to read
229229 if ($ bits ->available () < 4 ) {
230- throw FormatException:: getFormatInstance ("One digit left to read, but < 4 bits available " );
230+ throw new FormatException ("One digit left to read, but < 4 bits available " );
231231 }
232232 $ digitBits = $ bits ->readBits (4 );
233233 if ($ digitBits >= 10 ) {
234- throw FormatException:: getFormatInstance ("Too many bits: $ digitBits expected < 10 " );
234+ throw new FormatException ("Too many bits: $ digitBits expected < 10 " );
235235 }
236236 $ result .= (self ::toAlphaNumericChar ($ digitBits ));
237237 }
@@ -243,10 +243,10 @@ private static function decodeNumericSegment(
243243 private static function toAlphaNumericChar (int |float $ value )
244244 {
245245 if ($ value >= count (self ::$ ALPHANUMERIC_CHARS )) {
246- throw FormatException:: getFormatInstance ("$ value has too many alphanumeric chars " );
246+ throw new FormatException ("$ value has too many alphanumeric chars " );
247247 }
248248
249- return self ::$ ALPHANUMERIC_CHARS [$ value ];
249+ return self ::$ ALPHANUMERIC_CHARS [( int ) round ( $ value) ];
250250 }
251251
252252 private static function decodeAlphanumericSegment (
@@ -259,7 +259,7 @@ private static function decodeAlphanumericSegment(
259259 $ start = strlen ((string ) $ result );
260260 while ($ count > 1 ) {
261261 if ($ bits ->available () < 11 ) {
262- throw FormatException:: getFormatInstance ("Not enough bits available to read two expected characters " );
262+ throw new FormatException ("Not enough bits available to read two expected characters " );
263263 }
264264 $ nextTwoCharsBits = $ bits ->readBits (11 );
265265 $ result .= (self ::toAlphaNumericChar ($ nextTwoCharsBits / 45 ));
@@ -269,7 +269,7 @@ private static function decodeAlphanumericSegment(
269269 if ($ count == 1 ) {
270270 // special case: one character left
271271 if ($ bits ->available () < 6 ) {
272- throw FormatException:: getFormatInstance ("Not enough bits available to read one expected character " );
272+ throw new FormatException ("Not enough bits available to read one expected character " );
273273 }
274274 $ result .= self ::toAlphaNumericChar ($ bits ->readBits (6 ));
275275 }
@@ -300,7 +300,7 @@ private static function decodeByteSegment(
300300 ): void {
301301 // Don't crash trying to read more bits than we have available.
302302 if (8 * $ count > $ bits ->available ()) {
303- throw FormatException:: getFormatInstance ("Trying to read more bits than we have available " );
303+ throw new FormatException ("Trying to read more bits than we have available " );
304304 }
305305
306306 $ readBytes = fill_array (0 , $ count , 0 );
@@ -337,7 +337,7 @@ private static function decodeKanjiSegment(
337337 ): void {
338338 // Don't crash trying to read more bits than we have available.
339339 if ($ count * 13 > $ bits ->available ()) {
340- throw FormatException:: getFormatInstance ("Trying to read more bits than we have available " );
340+ throw new FormatException ("Trying to read more bits than we have available " );
341341 }
342342
343343 // Each character will require 2 bytes. Read the characters as 2-byte pairs
0 commit comments