Showing 27 of 27 total issues
Function __construct
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(\stdClass $oData = null, \stdClass $oLayers = null)
{
parent::__construct($oData);
if ($oData) {
$this->id = $this->convertToId($this->id);
- 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 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(\stdClass $oData = null, \stdClass $oLayers = null)
{
parent::__construct($oData);
if ($oData) {
$this->id = $this->convertToId($this->id);
The class KrsPerson has 16 fields. Consider redesigning KrsPerson to keep the number of fields under 15. Open
class KrsPerson extends ModelAbstract
{
const CONTEXT = 'krs_osoby';
const PULL_NONE = 0;
const PULL_KRS_ENTITIES = 1;
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
The class KrsEntity has 77 fields. Consider redesigning KrsEntity to keep the number of fields under 15. Open
class KrsEntity extends ModelAbstract
{
const CONTEXT = 'krs_podmioty';
const PULL_NONE = 0;
const PULL_COMPANIES = 1;
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
The class Commune has 26 fields. Consider redesigning Commune to keep the number of fields under 15. Open
class Commune extends ModelAbstract
{
const CONTEXT = 'gminy';
/**
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Function __construct
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(string $nts = null)
{
if (null === $nts || \strlen($nts) < 10) {
Api::getInstance()
->getClient()
- 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 getKrsEntity
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getKrsEntity($krs, int $pullFlag = KrsEntity::PULL_NONE): KrsEntity
{
$krs = (int)$krs;
$qb = QueryBuilder::create(KrsEntity::class)
->addLayer('jedynyAkcjonariusz')
The class KrsEntity has 78 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class KrsEntity extends ModelAbstract
{
const CONTEXT = 'krs_podmioty';
const PULL_NONE = 0;
const PULL_COMPANIES = 1;
- Read upRead up
- Exclude checks
ExcessivePublicCount
Since: 0.1
A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
Example
public class Foo {
public $value;
public $something;
public $var;
// [... more more public attributes ...]
public function doWork() {}
public function doMoreWork() {}
public function doWorkAgain() {}
// [... more more public methods ...]
}
Source https://phpmd.org/rules/codesize.html#excessivepubliccount
Method __construct
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(string $nts = null)
{
if (null === $nts || \strlen($nts) < 10) {
Api::getInstance()
->getClient()
Method get
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get(): SearchResponse
{
$res = Api::getInstance()
->getClient()
Function __construct
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(\stdClass $oData = null, \stdClass $oLayers = null)
{
if (null !== $oData) {
foreach ($oData as $key => $value) {
$key = $this->stripProperty($key);
- 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 getKrsEntity
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getKrsEntity($krs, int $pullFlag = KrsEntity::PULL_NONE): KrsEntity
{
$krs = (int)$krs;
$qb = QueryBuilder::create(KrsEntity::class)
->addLayer('jedynyAkcjonariusz')
- 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 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(string $self = null, string $first = null, string $next = null, string $last = null, string $prev = null)
Missing class import via use statement (line '55', column '28'). Open
$reflectionA = new \ReflectionClass($returnedClass);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '512', column '79'). Open
$this->data_sprawdzenia = $this->data_sprawdzenia ? (new \DateTime($this->data_sprawdzenia))->format('Y-m-d H:i:s') : null;
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '62', column '31'). Open
throw new \RuntimeException('KRS id not found in href');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '111', column '66'). Open
$this->data_urodzenia = $this->data_urodzenia ? (new \DateTime($this->data_urodzenia))->format('Y-m-d') : null;
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid unused parameters such as '$oLayers'. Open
public function __construct(\stdClass $oData = null, \stdClass $oLayers = null)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
The method where uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->query['conditions'][sprintf('%s.%s', $this->sContext, $property)] = $value;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new \RuntimeException('KRS id not found in href');
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}