@@ -111,12 +111,12 @@ public function setSize(
111111 ): static {
112112 $ this ->width = $ width ;
113113 if ($ this ->width <= 0 ) {
114- $ this ->width = (abs (min (-1 , $ this ->width )) * $ this ->ncols );
114+ $ this ->width = (\ abs (\ min (-1 , $ this ->width )) * $ this ->ncols );
115115 }
116116
117117 $ this ->height = $ height ;
118118 if ($ this ->height <= 0 ) {
119- $ this ->height = (abs (min (-1 , $ this ->height )) * $ this ->nrows );
119+ $ this ->height = (\ abs (\ min (-1 , $ this ->height )) * $ this ->nrows );
120120 }
121121
122122 $ this ->width_ratio = ($ this ->width / $ this ->ncols );
@@ -138,7 +138,7 @@ public function setSize(
138138 */
139139 protected function setPadding (array $ padding ): static
140140 {
141- if (count ($ padding ) != 4 ) {
141+ if (\ count ($ padding ) != 4 ) {
142142 throw new BarcodeException (
143143 'Invalid padding, expecting an array of 4 numbers (top, right, bottom, left) '
144144 );
@@ -152,7 +152,7 @@ protected function setPadding(array $padding): static
152152 ];
153153 foreach ($ padding as $ key => $ val ) {
154154 if ($ val < 0 ) {
155- $ val = (abs (min (-1 , $ val )) * $ map [$ key ][1 ]);
155+ $ val = (\ abs (\ min (-1 , $ val )) * $ map [$ key ][1 ]);
156156 }
157157
158158 $ this ->padding [$ map [$ key ][0 ]] = (int ) $ val ;
@@ -284,19 +284,19 @@ protected function getHTTPFile(
284284 string $ fileext ,
285285 ?string $ filename = null ,
286286 ): void {
287- if (is_null ($ filename ) || (preg_match ('/^[a-zA-Z0-9_\-]{1,250}$/ ' , $ filename ) !== 1 )) {
288- $ filename = md5 ($ data );
287+ if (\ is_null ($ filename ) || (\ preg_match ('/^[a-zA-Z0-9_\-]{1,250}$/ ' , $ filename ) !== 1 )) {
288+ $ filename = \ md5 ($ data );
289289 }
290290
291- header ('Content-Type: ' . $ mime );
292- header ('Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1 ' );
293- header ('Pragma: public ' );
294- header ('Expires: Thu, 04 jan 1973 00:00:00 GMT ' ); // Date in the past
295- header ('Last-Modified: ' . gmdate ('D, d M Y H:i:s ' ) . ' GMT ' );
296- header ('Content-Disposition: inline; filename=" ' . $ filename . '. ' . $ fileext . '"; ' );
291+ \ header ('Content-Type: ' . $ mime );
292+ \ header ('Cache-Control: private, must-revalidate, post-check=0, pre-check=0, max-age=1 ' );
293+ \ header ('Pragma: public ' );
294+ \ header ('Expires: Thu, 04 jan 1973 00:00:00 GMT ' ); // Date in the past
295+ \ header ('Last-Modified: ' . gmdate ('D, d M Y H:i:s ' ) . ' GMT ' );
296+ \ header ('Content-Disposition: inline; filename=" ' . $ filename . '. ' . $ fileext . '"; ' );
297297 if (empty ($ _SERVER ['HTTP_ACCEPT_ENCODING ' ])) {
298298 // the content length may vary if the server is using compression
299- header ('Content-Length: ' . strlen ($ data ));
299+ \ header ('Content-Length: ' . \ strlen ($ data ));
300300 }
301301
302302 echo $ data ;
@@ -324,12 +324,12 @@ public function getInlineSvgCode(): string
324324 {
325325 // flags for htmlspecialchars
326326 $ hflag = ENT_NOQUOTES ;
327- if (defined ('ENT_XML1 ' ) && defined ('ENT_DISALLOWED ' )) {
327+ if (\ defined ('ENT_XML1 ' ) && \ defined ('ENT_DISALLOWED ' )) {
328328 $ hflag = ENT_XML1 | ENT_DISALLOWED ;
329329 }
330330
331- $ width = sprintf ('%F ' , ($ this ->width + $ this ->padding ['L ' ] + $ this ->padding ['R ' ]));
332- $ height = sprintf ('%F ' , ($ this ->height + $ this ->padding ['T ' ] + $ this ->padding ['B ' ]));
331+ $ width = \ sprintf ('%F ' , ($ this ->width + $ this ->padding ['L ' ] + $ this ->padding ['R ' ]));
332+ $ height = \ sprintf ('%F ' , ($ this ->height + $ this ->padding ['T ' ] + $ this ->padding ['B ' ]));
333333
334334 $ svg = '<svg '
335335 . ' version="1.2" '
@@ -341,7 +341,7 @@ public function getInlineSvgCode(): string
341341 . ' height=" ' . $ height . '" '
342342 . ' viewBox="0 0 ' . $ width . ' ' . $ height . '" '
343343 . '> ' . "\n"
344- . "\t" . '<desc> ' . htmlspecialchars ($ this ->code , $ hflag , 'UTF-8 ' ) . '</desc> ' . "\n" ;
344+ . "\t" . '<desc> ' . \ htmlspecialchars ($ this ->code , $ hflag , 'UTF-8 ' ) . '</desc> ' . "\n" ;
345345 if ($ this ->bg_color_obj instanceof \Com \Tecnick \Color \Model \Rgb) {
346346 $ svg .= ' <rect x="0" y="0" width=" ' . $ width . '" '
347347 . ' height=" ' . $ height . '" '
@@ -359,10 +359,10 @@ public function getInlineSvgCode(): string
359359 . '> ' . "\n" ;
360360 $ bars = $ this ->getBarsArrayXYWH ();
361361 foreach ($ bars as $ bar ) {
362- $ svg .= ' <rect x=" ' . sprintf ('%F ' , $ bar [0 ]) . '" '
363- . ' y=" ' . sprintf ('%F ' , $ bar [1 ]) . '" '
364- . ' width=" ' . sprintf ('%F ' , $ bar [2 ]) . '" '
365- . ' height=" ' . sprintf ('%F ' , $ bar [3 ]) . '" '
362+ $ svg .= ' <rect x=" ' . \ sprintf ('%F ' , $ bar [0 ]) . '" '
363+ . ' y=" ' . \ sprintf ('%F ' , $ bar [1 ]) . '" '
364+ . ' width=" ' . \ sprintf ('%F ' , $ bar [2 ]) . '" '
365+ . ' height=" ' . \ sprintf ('%F ' , $ bar [3 ]) . '" '
366366 . ' /> ' . "\n" ;
367367 }
368368
@@ -389,8 +389,14 @@ public function getSvgCode(): string
389389 */
390390 public function getHtmlDiv (): string
391391 {
392- $ html = '<div style="width: ' . sprintf ('%F ' , ($ this ->width + $ this ->padding ['L ' ] + $ this ->padding ['R ' ])) . 'px; '
393- . 'height: ' . sprintf ('%F ' , ($ this ->height + $ this ->padding ['T ' ] + $ this ->padding ['B ' ])) . 'px; '
392+ $ html = '<div style="width: ' . \sprintf (
393+ '%F ' ,
394+ ($ this ->width + $ this ->padding ['L ' ] + $ this ->padding ['R ' ])
395+ ) . 'px; '
396+ . 'height: ' . \sprintf (
397+ '%F ' ,
398+ ($ this ->height + $ this ->padding ['T ' ] + $ this ->padding ['B ' ])
399+ ) . 'px; '
394400 . 'position:relative; '
395401 . 'font-size:0; '
396402 . 'border:none; '
@@ -404,10 +410,10 @@ public function getHtmlDiv(): string
404410 $ bars = $ this ->getBarsArrayXYWH ();
405411 foreach ($ bars as $ bar ) {
406412 $ html .= ' <div style="background-color: ' . $ this ->color_obj ->getCssColor () . '; '
407- . 'left: ' . sprintf ('%F ' , $ bar [0 ]) . 'px; '
408- . 'top: ' . sprintf ('%F ' , $ bar [1 ]) . 'px; '
409- . 'width: ' . sprintf ('%F ' , $ bar [2 ]) . 'px; '
410- . 'height: ' . sprintf ('%F ' , $ bar [3 ]) . 'px; '
413+ . 'left: ' . \ sprintf ('%F ' , $ bar [0 ]) . 'px; '
414+ . 'top: ' . \ sprintf ('%F ' , $ bar [1 ]) . 'px; '
415+ . 'width: ' . \ sprintf ('%F ' , $ bar [2 ]) . 'px; '
416+ . 'height: ' . \ sprintf ('%F ' , $ bar [3 ]) . 'px; '
411417 . 'position:absolute; '
412418 . 'border:none; '
413419 . 'padding:0; '
@@ -440,14 +446,14 @@ public function getPng(?string $filename = null): void
440446 */
441447 public function getPngData (bool $ imagick = true ): string
442448 {
443- if ($ imagick && extension_loaded ('imagick ' )) {
449+ if ($ imagick && \ extension_loaded ('imagick ' )) {
444450 return $ this ->getPngDataImagick ();
445451 }
446452
447453 $ gdImage = $ this ->getGd ();
448- ob_start ();
449- imagepng ($ gdImage );
450- $ data = ob_get_clean ();
454+ \ ob_start ();
455+ \ imagepng ($ gdImage );
456+ $ data = \ ob_get_clean ();
451457 if ($ data === false ) {
452458 throw new BarcodeException ('Unable to get PNG data ' );
453459 }
@@ -462,8 +468,8 @@ public function getPngData(bool $imagick = true): string
462468 public function getPngDataImagick (): string
463469 {
464470 $ imagick = new \Imagick ();
465- $ width = (int ) ceil ($ this ->width + $ this ->padding ['L ' ] + $ this ->padding ['R ' ]);
466- $ height = (int ) ceil ($ this ->height + $ this ->padding ['T ' ] + $ this ->padding ['B ' ]);
471+ $ width = (int ) \ ceil ($ this ->width + $ this ->padding ['L ' ] + $ this ->padding ['R ' ]);
472+ $ height = (int ) \ ceil ($ this ->height + $ this ->padding ['T ' ] + $ this ->padding ['B ' ]);
467473 $ imagick ->newImage ($ width , $ height , 'none ' , 'png ' );
468474 $ imagickdraw = new \imagickdraw ();
469475 if ($ this ->bg_color_obj instanceof \Com \Tecnick \Color \Model \Rgb) {
@@ -492,58 +498,58 @@ public function getPngDataImagick(): string
492498 */
493499 public function getGd (): \GdImage
494500 {
495- $ width = max (1 , (int ) ceil ($ this ->width + $ this ->padding ['L ' ] + $ this ->padding ['R ' ]));
496- $ height = max (1 , (int ) ceil ($ this ->height + $ this ->padding ['T ' ] + $ this ->padding ['B ' ]));
497- $ img = imagecreate ($ width , $ height );
501+ $ width = \ max (1 , (int ) \ ceil ($ this ->width + $ this ->padding ['L ' ] + $ this ->padding ['R ' ]));
502+ $ height = \ max (1 , (int ) \ ceil ($ this ->height + $ this ->padding ['T ' ] + $ this ->padding ['B ' ]));
503+ $ img = \ imagecreate ($ width , $ height );
498504 if ($ img === false ) {
499505 throw new BarcodeException ('Unable to create GD image ' );
500506 }
501507
502508 if (! $ this ->bg_color_obj instanceof \Com \Tecnick \Color \Model \Rgb) {
503509 $ bgobj = clone $ this ->color_obj ;
504510 $ rgbcolor = $ bgobj ->invertColor ()->getNormalizedArray (255 );
505- $ background_color = imagecolorallocate (
511+ $ background_color = \ imagecolorallocate (
506512 $ img ,
507- (int ) round ($ rgbcolor ['R ' ]), // @phpstan-ignore argument.type
508- (int ) round ($ rgbcolor ['G ' ]), // @phpstan-ignore argument.type
509- (int ) round ($ rgbcolor ['B ' ]), // @phpstan-ignore argument.type
513+ (int ) \ round ($ rgbcolor ['R ' ]), // @phpstan-ignore argument.type
514+ (int ) \ round ($ rgbcolor ['G ' ]), // @phpstan-ignore argument.type
515+ (int ) \ round ($ rgbcolor ['B ' ]), // @phpstan-ignore argument.type
510516 );
511517 if ($ background_color === false ) {
512518 throw new BarcodeException ('Unable to allocate default GD background color ' );
513519 }
514- imagecolortransparent ($ img , $ background_color );
520+ \ imagecolortransparent ($ img , $ background_color );
515521 } else {
516522 $ rgbcolor = $ this ->bg_color_obj ->getNormalizedArray (255 );
517- $ bg_color = imagecolorallocate (
523+ $ bg_color = \ imagecolorallocate (
518524 $ img ,
519- (int ) round ($ rgbcolor ['R ' ]), // @phpstan-ignore argument.type
520- (int ) round ($ rgbcolor ['G ' ]), // @phpstan-ignore argument.type
521- (int ) round ($ rgbcolor ['B ' ]), // @phpstan-ignore argument.type
525+ (int ) \ round ($ rgbcolor ['R ' ]), // @phpstan-ignore argument.type
526+ (int ) \ round ($ rgbcolor ['G ' ]), // @phpstan-ignore argument.type
527+ (int ) \ round ($ rgbcolor ['B ' ]), // @phpstan-ignore argument.type
522528 );
523529 if ($ bg_color === false ) {
524530 throw new BarcodeException ('Unable to allocate GD background color ' );
525531 }
526- imagefilledrectangle ($ img , 0 , 0 , $ width , $ height , $ bg_color );
532+ \ imagefilledrectangle ($ img , 0 , 0 , $ width , $ height , $ bg_color );
527533 }
528534
529535 $ rgbcolor = $ this ->color_obj ->getNormalizedArray (255 );
530- $ bar_color = imagecolorallocate (
536+ $ bar_color = \ imagecolorallocate (
531537 $ img ,
532- (int ) round ($ rgbcolor ['R ' ]), // @phpstan-ignore argument.type
533- (int ) round ($ rgbcolor ['G ' ]), // @phpstan-ignore argument.type
534- (int ) round ($ rgbcolor ['B ' ]), // @phpstan-ignore argument.type
538+ (int ) \ round ($ rgbcolor ['R ' ]), // @phpstan-ignore argument.type
539+ (int ) \ round ($ rgbcolor ['G ' ]), // @phpstan-ignore argument.type
540+ (int ) \ round ($ rgbcolor ['B ' ]), // @phpstan-ignore argument.type
535541 );
536542 if ($ bar_color === false ) {
537543 throw new BarcodeException ('Unable to allocate GD foreground color ' );
538544 }
539545 $ bars = $ this ->getBarsArrayXYXY ();
540546 foreach ($ bars as $ bar ) {
541- imagefilledrectangle (
547+ \ imagefilledrectangle (
542548 $ img ,
543- (int ) floor ($ bar [0 ]),
544- (int ) floor ($ bar [1 ]),
545- (int ) floor ($ bar [2 ]),
546- (int ) floor ($ bar [3 ]),
549+ (int ) \ floor ($ bar [0 ]),
550+ (int ) \ floor ($ bar [1 ]),
551+ (int ) \ floor ($ bar [2 ]),
552+ (int ) \ floor ($ bar [3 ]),
547553 $ bar_color
548554 );
549555 }
@@ -564,7 +570,7 @@ public function getGrid(
564570 $ raw = $ this ->getGridArray ($ space_char , $ bar_char );
565571 $ grid = '' ;
566572 foreach ($ raw as $ row ) {
567- $ grid .= implode ('' , $ row ) . "\n" ;
573+ $ grid .= \ implode ('' , $ row ) . "\n" ;
568574 }
569575
570576 return $ grid ;
0 commit comments