:octocat: simplified mask pattern tester call

This commit is contained in:
codemasher
2018-03-13 18:24:12 +01:00
parent c70413232b
commit aac41883d0
3 changed files with 3 additions and 11 deletions
+1 -5
View File
@@ -37,14 +37,10 @@ class MaskPatternTester{
* @see \chillerlan\QRCode\QRCode::getBestMaskPattern()
*
* @param \chillerlan\QRCode\Data\QRMatrix $matrix
*
* @return \chillerlan\QRCode\Data\MaskPatternTester
*/
public function setMatrix(QRMatrix $matrix):MaskPatternTester{
public function __construct(QRMatrix $matrix){
$this->matrix = $matrix;
$this->moduleCount = $this->matrix->size();
return $this;
}
/**
+1 -5
View File
@@ -197,16 +197,12 @@ class QRCode{
protected function getBestMaskPattern():int{
$penalties = [];
$tester = new MaskPatternTester;
for($testPattern = 0; $testPattern < 8; $testPattern++){
$matrix = $this
->dataInterface
->initMatrix($testPattern, true);
$tester->setMatrix($matrix);
$penalties[$testPattern] = $tester->testPattern();
$penalties[$testPattern] = (new MaskPatternTester($matrix))->testPattern();
}
return array_search(min($penalties), $penalties, true);
+1 -1
View File
@@ -25,7 +25,7 @@ class MaskPatternTesterTest extends QRTestAbstract{
public function testMaskpattern(){
$matrix = (new Byte(new QROptions(['version' => 10]), 'test'))->initMatrix(0, true);
$this->assertSame(6178, (new MaskPatternTester)->setMatrix($matrix)->testPattern());
$this->assertSame(6178, (new MaskPatternTester($matrix))->testPattern());
}