Skip to content

Commit 53e2d8f

Browse files
committed
🚿
1 parent 44d277d commit 53e2d8f

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/Common/LuminanceSourceAbstract.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use chillerlan\QRCode\QROptions;
1717
use chillerlan\QRCode\Decoder\QRCodeDecoderException;
1818
use chillerlan\Settings\SettingsContainerInterface;
19-
use function array_slice, array_splice, file_exists, is_file, is_readable, realpath;
19+
use function array_slice, file_exists, is_file, is_readable, realpath;
2020

2121
/**
2222
* The purpose of this class hierarchy is to abstract different bitmap implementations across
@@ -28,16 +28,14 @@ abstract class LuminanceSourceAbstract implements LuminanceSourceInterface{
2828

2929
protected SettingsContainerInterface|QROptions $options;
3030
/** @var int[] */
31-
protected array $luminances;
31+
protected array $luminances = [];
3232
protected int $width;
3333
protected int $height;
3434

3535
public function __construct(int $width, int $height, SettingsContainerInterface|QROptions $options = new QROptions){
3636
$this->width = $width;
3737
$this->height = $height;
3838
$this->options = $options;
39-
40-
$this->luminances = [];
4139
}
4240

4341
public function getLuminances():array{
@@ -54,15 +52,11 @@ public function getHeight():int{
5452

5553
public function getRow(int $y):array{
5654

57-
if($y < 0 || $y >= $this->getHeight()){
55+
if($y < 0 || $y >= $this->height){
5856
throw new QRCodeDecoderException('Requested row is outside the image: '.$y);
5957
}
6058

61-
$arr = [];
62-
63-
array_splice($arr, 0, $this->width, array_slice($this->luminances, ($y * $this->width), $this->width));
64-
65-
return $arr;
59+
return array_slice($this->luminances, ($y * $this->width), $this->width);
6660
}
6761

6862
protected function setLuminancePixel(int $r, int $g, int $b):void{

0 commit comments

Comments
 (0)