File qrcode.php
has 1688 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
//============================================================+
// File name : qrcode.php
// Begin : 2010-03-22
// Last Update : 2010-03-29
QRcode
has 98 functions (exceeds 20 allowed). Consider refactoring. Open
class QRcode {
/**
* @var barcode array to be returned which is readable by TCPDF
* @access protected
Function evaluateSymbol
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
protected function evaluateSymbol($width, $frame) {
$head = 0;
$demerit = 0;
for ($y=0; $y<$width; ++$y) {
$head = 0;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function eat8
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
protected function eat8() {
$la = $this->lengthIndicator(QR_MODE_AN, $this->version);
$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
$p = 1;
$dataStrLen = strlen($this->dataStr);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function init_rs_char
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
protected function init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) {
// Based on Reed solomon encoder by Phil Karn, KA9Q (GNU-LGPLv2)
$rs = null;
// Check parameter ranges
if (($symsize < 0) OR ($symsize > 8)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function calcN1N3
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
protected function calcN1N3($length) {
$demerit = 0;
for ($i=0; $i<$length; ++$i) {
if ($this->runLength[$i] >= 5) {
$demerit += (N1 + ($this->runLength[$i] - 5));
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getNextPosition
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
protected function getNextPosition() {
do {
if ($this->bit == -1) {
$this->bit = 0;
return array('x'=>$this->x, 'y'=>$this->y);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function createFrame
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
protected function createFrame($version) {
$width = $this->capacity[$version][QRCAP_WIDTH];
$frameLine = str_repeat ("\0", $width);
$frame = array_fill(0, $width, $frameLine);
// Finder pattern
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function eatAn
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
protected function eatAn() {
$la = $this->lengthIndicator(QR_MODE_AN, $this->version);
$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
$p = 0;
while($this->isalnumat($this->dataStr, $p)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function splitString
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected function splitString() {
while (strlen($this->dataStr) > 0) {
if ($this->dataStr == '') {
return 0;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function encodeMask
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected function encodeMask($mask) {
$spec = array(0, 0, 0, 0, 0);
$this->datacode = $this->getByteStream($this->items);
if (is_null($this->datacode)) {
return NULL;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function writeFormatInformation
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected function writeFormatInformation($width, &$frame, $mask, $level) {
$blacks = 0;
$format = $this->getFormatInfo($mask, $level);
for ($i=0; $i<8; ++$i) {
if ($format & 1) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method init_rs_char
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) {
// Based on Reed solomon encoder by Phil Karn, KA9Q (GNU-LGPLv2)
$rs = null;
// Check parameter ranges
if (($symsize < 0) OR ($symsize > 8)) {
Function lengthOfCode
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function lengthOfCode($mode, $version, $bits) {
$payload = $bits - 4 - $this->lengthIndicator($mode, $version);
switch($mode) {
case QR_MODE_NM: {
$chunks = (int)($payload / 10);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method evaluateSymbol
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function evaluateSymbol($width, $frame) {
$head = 0;
$demerit = 0;
for ($y=0; $y<$width; ++$y) {
$head = 0;
Method createFrame
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function createFrame($version) {
$width = $this->capacity[$version][QRCAP_WIDTH];
$frameLine = str_repeat ("\0", $width);
$frame = array_fill(0, $width, $frameLine);
// Finder pattern
Method encodeMask
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function encodeMask($mask) {
$spec = array(0, 0, 0, 0, 0);
$this->datacode = $this->getByteStream($this->items);
if (is_null($this->datacode)) {
return NULL;
Method lengthOfCode
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function lengthOfCode($mode, $version, $bits) {
$payload = $bits - 4 - $this->lengthIndicator($mode, $version);
switch($mode) {
case QR_MODE_NM: {
$chunks = (int)($payload / 10);
Method init
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function init($spec) {
$dl = $this->rsDataCodes1($spec);
$el = $this->rsEccCodes1($spec);
$rs = $this->init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
$blockNo = 0;
Method getNextPosition
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getNextPosition() {
do {
if ($this->bit == -1) {
$this->bit = 0;
return array('x'=>$this->x, 'y'=>$this->y);
Function identifyMode
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function identifyMode($pos) {
if ($pos >= strlen($this->dataStr)) {
return QR_MODE_NL;
}
$c = $this->dataStr[$pos];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function putAlignmentPattern
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function putAlignmentPattern($version, $frame, $width) {
if ($version < 2) {
return $frame;
}
$d = $this->alignmentPattern[$version][1] - $this->alignmentPattern[$version][0];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method eat8
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function eat8() {
$la = $this->lengthIndicator(QR_MODE_AN, $this->version);
$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
$p = 1;
$dataStrLen = strlen($this->dataStr);
Function encode_rs_char
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function encode_rs_char($rs, $data, $parity) {
$MM =& $rs['mm']; // bits per symbol
$NN =& $rs['nn']; // the total number of symbols in a RS block
$ALPHA_TO =& $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form
$INDEX_OF =& $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function convertData
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function convertData($items) {
$ver = $this->estimateVersion($items);
if ($ver > $this->version) {
$this->version = $ver;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __construct
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($code, $eclevel = 'L') {
$barcode_array = array();
if ((is_null($code)) OR ($code == '\0') OR ($code == '')) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method encodeBitStream
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function encodeBitStream($inputitem, $version) {
$inputitem['bstream'] = array();
$words = $this->maximumWords($inputitem['mode'], $version);
if ($inputitem['size'] > $words) {
$st1 = $this->newInputItem($inputitem['mode'], $words, $inputitem['data']);
Function eatNum
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function eatNum() {
$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
$p = 0;
while($this->isdigitat($this->dataStr, $p)) {
$p++;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function bitstreamToByte
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function bitstreamToByte($bstream) {
$size = count($bstream);
if ($size == 0) {
return array();
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method estimateBitStreamSize
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function estimateBitStreamSize($items, $version) {
$bits = 0;
if ($version == 0) {
$version = 1;
}
Method splitString
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function splitString() {
while (strlen($this->dataStr) > 0) {
if ($this->dataStr == '') {
return 0;
}
Method writeFormatInformation
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function writeFormatInformation($width, &$frame, $mask, $level) {
$blacks = 0;
$format = $this->getFormatInfo($mask, $level);
for ($i=0; $i<8; ++$i) {
if ($format & 1) {
Method eatAn
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function eatAn() {
$la = $this->lengthIndicator(QR_MODE_AN, $this->version);
$ln = $this->lengthIndicator(QR_MODE_NM, $this->version);
$p = 0;
while($this->isalnumat($this->dataStr, $p)) {
Method putAlignmentPattern
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function putAlignmentPattern($version, $frame, $width) {
if ($version < 2) {
return $frame;
}
$d = $this->alignmentPattern[$version][1] - $this->alignmentPattern[$version][0];
Function makeMaskNo
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly=false) {
$b = 0;
$bitMask = array();
$bitMask = $this->generateMaskNo($maskNo, $width, $s, $d);
if ($maskGenOnly) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function maximumWords
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function maximumWords($mode, $version) {
if ($mode == QR_MODE_ST) {
return 3;
}
if ($version <= 9) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method __construct
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($code, $eclevel = 'L') {
$barcode_array = array();
if ((is_null($code)) OR ($code == '\0') OR ($code == '')) {
return false;
}
Method mask
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function mask($width, $frame, $level) {
$minDemerit = PHP_INT_MAX;
$bestMaskNum = 0;
$bestMask = array();
$checked_masks = array(0, 1, 2, 3, 4, 5, 6, 7);
Method encode_rs_char
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function encode_rs_char($rs, $data, $parity) {
$MM =& $rs['mm']; // bits per symbol
$NN =& $rs['nn']; // the total number of symbols in a RS block
$ALPHA_TO =& $rs['alpha_to']; // the address of an array of NN elements to convert Galois field elements in index (log) form to polynomial form
$INDEX_OF =& $rs['index_of']; // the address of an array of NN elements to convert Galois field elements in polynomial form to index (log) form
Function newFromBytes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function newFromBytes($size, $data) {
$bstream = $this->allocate($size * 8);
$p=0;
for ($i=0; $i<$size; ++$i) {
$mask = 0x80;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function mask
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function mask($width, $frame, $level) {
$minDemerit = PHP_INT_MAX;
$bestMaskNum = 0;
$bestMask = array();
$checked_masks = array(0, 1, 2, 3, 4, 5, 6, 7);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function generateMaskNo
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function generateMaskNo($maskNo, $width, $frame) {
$bitMask = array_fill(0, $width, array_fill(0, $width, 0));
for ($y=0; $y<$width; ++$y) {
for ($x=0; $x<$width; ++$x) {
if (ord($frame[$y][$x]) & 0x80) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function toUpper
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function toUpper() {
$stringLen = strlen($this->dataStr);
$p = 0;
while ($p < $stringLen) {
$mode = $this->identifyMode(substr($this->dataStr, $p), $this->hint);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function encodeBitStream
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function encodeBitStream($inputitem, $version) {
$inputitem['bstream'] = array();
$words = $this->maximumWords($inputitem['mode'], $version);
if ($inputitem['size'] > $words) {
$st1 = $this->newInputItem($inputitem['mode'], $words, $inputitem['data']);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method bitstreamToByte
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function bitstreamToByte($bstream) {
$size = count($bstream);
if ($size == 0) {
return array();
}
Function appendPaddingBit
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function appendPaddingBit($bstream) {
$bits = count($bstream);
$maxwords = $this->getDataLength($this->version, $this->level);
$maxbits = $maxwords * 8;
if ($maxbits == $bits) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function estimateBitStreamSize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function estimateBitStreamSize($items, $version) {
$bits = 0;
if ($version == 0) {
$version = 1;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function calcParity
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function calcParity($items) {
$parity = 0;
foreach ($items as $item) {
if ($item['mode'] != QR_MODE_ST) {
for ($i=$item['size']-1; $i>=0; --$i) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
if (($b22 | ($w22 ^ 1)) & 1) {
$demerit += N2;
}
Function init
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function init($spec) {
$dl = $this->rsDataCodes1($spec);
$el = $this->rsEccCodes1($spec);
$rs = $this->init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
$blockNo = 0;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method init_rs
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) {
Avoid deeply nested control flow statements. Open
if (($this->runLength[$i-2] == $fact)
AND ($this->runLength[$i-1] == $fact)
AND ($this->runLength[$i+1] == $fact)
AND ($this->runLength[$i+2] == $fact)) {
if (($this->runLength[$i-3] < 0) OR ($this->runLength[$i-3] >= (4 * $fact))) {
Method init_rs_char
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) {
Method makeMaskNo
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly=false) {
Method qrstrset
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function qrstrset($srctab, $x, $y, $repl, $replLen=false) {
Function getCode
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getCode() {
if ($this->count < $this->dataLength) {
$row = $this->count % $this->blocks;
$col = $this->count / $this->blocks;
if ($col >= $this->rsblocks[0]['dataLength']) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function checkModeKanji
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function checkModeKanji($size, $data) {
if ($size & 1) {
return false;
}
for ($i=0; $i<$size; $i+=2) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $rs;
Avoid too many return
statements within this method. Open
return NULL;
Avoid too many return
statements within this method. Open
return $rs;
Avoid too many return
statements within this method. Open
return QR_MODE_8B;
Function lengthIndicator
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function lengthIndicator($mode, $version) {
if ($mode == QR_MODE_ST) {
return 0;
}
if ($version <= 9) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function newFrame
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function newFrame($version) {
if (($version < 1) OR ($version > QRSPEC_VERSION_MAX)) {
return NULL;
}
if (!isset($this->frames[$version])) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function encodeModeKanji
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function encodeModeKanji($inputitem, $version) {
$inputitem['bstream'] = array();
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], 4, 0x8);
$inputitem['bstream'] = $this->appendNum($inputitem['bstream'], $this->lengthIndicator(QR_MODE_KJ, $version), (int)($inputitem['size'] / 2));
for ($i=0; $i<$inputitem['size']; $i+=2) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function newFromNum
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function newFromNum($bits, $num) {
$bstream = $this->allocate($bits);
$mask = 1 << ($bits - 1);
for ($i=0; $i<$bits; ++$i) {
if ($num & $mask) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function init_rs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) {
foreach ($this->rsitems as $rs) {
if (($rs['pad'] != $pad) OR ($rs['nroots'] != $nroots) OR ($rs['mm'] != $symsize)
OR ($rs['gfpoly'] != $gfpoly) OR ($rs['fcr'] != $fcr) OR ($rs['prim'] != $prim)) {
continue;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Identical blocks of code found in 2 locations. Consider refactoring. Open
for ($i=0; $i < $endfor; ++$i) {
$ecc = array_slice($this->ecccode, $eccPos);
$this->rsblocks[$blockNo] = array();
$this->rsblocks[$blockNo]['dataLength'] = $dl;
$this->rsblocks[$blockNo]['data'] = array_slice($this->datacode, $dataPos);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 213.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
for ($i=0; $i < $endfor; ++$i) {
$ecc = array_slice($this->ecccode, $eccPos);
$this->rsblocks[$blockNo] = array();
$this->rsblocks[$blockNo]['dataLength'] = $dl;
$this->rsblocks[$blockNo]['data'] = array_slice($this->datacode, $dataPos);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 213.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if ($this->isdigitat($this->dataStr, $p)) {
$q = $p;
while($this->isdigitat($this->dataStr, $q)) {
$q++;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 93.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
} elseif ($mode == QR_MODE_AN) {
$q = $p;
while($this->isalnumat($this->dataStr, $q)) {
$q++;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 93.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if ($mode == QR_MODE_NM) {
$q = $p;
while($this->isdigitat($this->dataStr, $q)) {
$q++;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 93.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76