🚿 allow testing of specific patterns

This commit is contained in:
codemasher
2020-04-03 20:12:44 +02:00
parent c01660f4a5
commit a8aad88979
2 changed files with 12 additions and 8 deletions
+5 -6
View File
@@ -46,10 +46,7 @@ final class MaskPatternTester{
$penalties = [];
for($pattern = 0; $pattern < 8; $pattern++){
$this->matrix = $this->dataInterface->initMatrix($pattern, true);
$this->moduleCount = $this->matrix->size();
$penalties[$pattern] = $this->testPattern();
$penalties[$pattern] = $this->testPattern($pattern);
}
return array_search(min($penalties), $penalties, true);
@@ -61,8 +58,10 @@ final class MaskPatternTester{
* @see \chillerlan\QRCode\QROptions::$maskPattern
* @see \chillerlan\QRCode\Data\QRMatrix::$maskPattern
*/
protected function testPattern():int{
$penalty = 0;
public function testPattern(int $pattern):int{
$this->matrix = $this->dataInterface->initMatrix($pattern, true);
$this->moduleCount = $this->matrix->size();
$penalty = 0;
for($level = 1; $level <= 4; $level++){
$penalty += call_user_func([$this, 'testLevel'.$level]);