The class OtpInit has an overall complexity of 62 which is very high. The configured complexity threshold is 50. Open
class OtpInit extends InputWidget
{
/**
* @var string
- Exclude checks
File OtpInit.php
has 268 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Author: Semen Dubina
* Date: 20.01.16
* Time: 4:22
Method initQr
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function initQr($text)
{
$level = ErrorCorrectionLevelInterface::QUARTILE;
$type = PngWriter::class;
Method decorateQr
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function decorateQr(QrCode $qrCode)
{
$foreColor = [0,0,0];
$backColor = [255,255,255];
Function initQr
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function initQr($text)
{
$level = ErrorCorrectionLevelInterface::QUARTILE;
$type = PngWriter::class;
- 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 decorateQr
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function decorateQr(QrCode $qrCode)
{
$foreColor = [0,0,0];
$backColor = [255,255,255];
- 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 checkParamOutfile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function checkParamOutfile($outfile)
{
if(is_string($outfile) && !is_dir(dirname($outfile))) {
throw new InvalidConfigException('OtpInit::$qrParams[\'outfile\'] error ' . dirname($outfile) . ' is not dir');
} elseif (!is_string($outfile) && $outfile !== 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
The class OtpInit has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. Open
class OtpInit extends InputWidget
{
/**
* @var string
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Avoid using static access to class '\yii\helpers\FileHelper' in method 'checkParamOutfile'. Open
FileHelper::createDirectory($dir);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\yii\helpers\Html' in method 'renderWidget'. Open
echo Html::a($this->link, $this->otp->getProvisioningUri());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\BaconQrCode\Common\CharacterSetEci' in method 'checkParamEncoding'. Open
if (CharacterSetEci::getCharacterSetECIByName($encoding) === null) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\yii\helpers\FileHelper' in method 'checkParamLogo'. Open
FileHelper::createDirectory($dir);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\yii\helpers\Html' in method 'renderWidget'. Open
echo Html::activeHiddenInput($this->model, $this->attribute, $this->options);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
There must be no space before the colon in a CASE statement Open
case JpgWriter::class :
- Exclude checks
There must be no space before the colon in a CASE statement Open
case PngWriter::class :
- Exclude checks
There must be no space before the colon in a CASE statement Open
case SvgWriter::class :
- Exclude checks
There must be no space before the colon in a CASE statement Open
case EpsWriter::class :
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$img = '<img src=' . $imgSrc . base64_encode($this->generateQr($this->otp->getProvisioningUri())) . ' />';
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
throw new InvalidConfigException('OtpInit::$qrParams[\'outfile\'] error ' . dirname($outfile) . ' is not dir');
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$img = '<img src=' . $imgSrc . base64_encode($this->generateQr($this->otp->getProvisioningUri())) . ' />';
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if(
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(is_string($outfile) && !is_dir(dirname($outfile))) {
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if($outfile === false) {
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(
- Exclude checks
Expected 1 space after IF keyword; 0 found Open
if(!is_subclass_of($type, WriterInterface::class)) {
- Exclude checks