:octocat: QRMatrix: allow retruning a pure boolean representation

This commit is contained in:
codemasher
2020-04-12 01:25:32 +02:00
parent 40f8bd2029
commit 0f21c91802
+19 -4
View File
@@ -258,12 +258,27 @@ final class QRMatrix{
}
/**
* Returns the data matrix
* Returns the data matrix, returns a pure boolean representation if $boolean is set to true
*
* @return int[][]
*/
public function matrix():array{
return $this->matrix;
public function matrix(bool $boolean = false):array{
if(!$boolean){
return $this->matrix;
}
$matrix = [];
foreach($this->matrix as $y => $row){
$matrix[$y] = [];
foreach($row as $x => $val){
$matrix[$y][$x] = ($val >> 8) > 0;
}
}
return $matrix;
}
/**
@@ -325,7 +340,7 @@ final class QRMatrix{
* $value >> 8 === 0
*/
public function check(int $x, int $y):bool{
return $this->matrix[$y][$x] >> 8 > 0;
return ($this->matrix[$y][$x] >> 8) > 0;
}