MCPcopy Create free account
hub / github.com/codemistic/Web-Development / calcN1N3

Method calcN1N3

text-to-qr/lib/phpqrcode/phpqrcode.php:2661–2687  ·  view source on GitHub ↗

----------------------------------------------------------------------

($length)

Source from the content-addressed store, hash-verified

2659
2660 //----------------------------------------------------------------------
2661 public function calcN1N3($length)
2662 {
2663 $demerit = 0;
2664
2665 for($i=0; $i<$length; $i++) {
2666
2667 if($this->runLength[$i] >= 5) {
2668 $demerit += (N1 + ($this->runLength[$i] - 5));
2669 }
2670 if($i & 1) {
2671 if(($i >= 3) && ($i < ($length-2)) && ($this->runLength[$i] % 3 == 0)) {
2672 $fact = (int)($this->runLength[$i] / 3);
2673 if(($this->runLength[$i-2] == $fact) &&
2674 ($this->runLength[$i-1] == $fact) &&
2675 ($this->runLength[$i+1] == $fact) &&
2676 ($this->runLength[$i+2] == $fact)) {
2677 if(($this->runLength[$i-3] < 0) || ($this->runLength[$i-3] >= (4 * $fact))) {
2678 $demerit += N3;
2679 } else if((($i+3) >= $length) || ($this->runLength[$i+3] >= (4 * $fact))) {
2680 $demerit += N3;
2681 }
2682 }
2683 }
2684 }
2685 }
2686 return $demerit;
2687 }
2688
2689 //----------------------------------------------------------------------
2690 public function evaluateSymbol($width, $frame)

Callers 1

evaluateSymbolMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected