mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-31 12:38:22 +00:00
:octocat: QRMatrix: allow retruning a pure boolean representation
This commit is contained in:
+19
-4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user