Showing 52 of 52 total issues
Method find
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function find(string $id)
{
switch (strlen($id)) {
case 6:
$provinceId = substr($id, 0, 2);
Function searchDistricts
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function searchDistricts(string $phrase = null)
{
try {
$answer = [];
if ($phrase) {
- 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 NativeApi has 55 public methods and attributes. Consider reducing the number of public items to less than 45. Open
final class NativeApi
{
/**
* @var string Wyszukiwanie wśród wszystkich rodzajów jednostek
*/
- 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
Function getKeyValues
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function getKeyValues(array $tItems, string $sKey, bool $asUnique = true): array
{
$answer = [];
foreach ($tItems as $item) {
if (!is_object($item) && !is_array($item)) {
- 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 WeryfikujNazwaAdresUlic
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
string $provinceName,
string $districtName,
string $communeName,
string $cityName,
string $cityTypeName = null,
Method WeryfikujNazwaAdresUlicAdresowy
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
string $provinceName,
string $districtName,
string $communeName,
string $cityName,
string $cityTypeName = null,
The class NativeApi has a coupling between objects value of 22. Consider to reduce the number of dependencies under 13. Open
final class NativeApi
{
/**
* @var string Wyszukiwanie wśród wszystkich rodzajów jednostek
*/
- 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
Method WyszukajUliceWRejestrze
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
string $name = null,
string $identityName = 'ul.',
string $streetId = null,
array $tSimc = [],
array $tTerc = []
Method WeryfikujAdresWmiejscowosci
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
string $provinceName,
string $districtName,
string $communeName,
string $cityName,
string $cityTypeName = null
Method WeryfikujAdresWmiejscowosciAdresowy
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
string $provinceName,
string $districtName,
string $communeName,
string $cityName,
string $cityTypeName = null
Method __doRequest
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __doRequest($request, $location, $action, $version, $oneWay = 0)
Method WyszukajMiejscowoscWJPT
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
string $provinceName,
string $districtName,
string $communeName,
string $cityName,
string $cityId = null
Method WyszukajMiejscowoscWRejestrze
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
string $name = null,
string $cityId = null,
array $tSimc = [],
array $tTerc = [],
string $cityTypeName = NativeApi::SEARCH_CITY_TYPE_ALL
Missing class import via use statement (line '68', column '58'). Open
$this->statusDate = $oData->DataStanu ? (new \DateTime($oData->DataStanu))->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 too many return
statements within this method. Open
return new Exception('Unknown Exception', 1, $e);
Avoid too many return
statements within this method. Open
return $e;
The method PobierzListeUlicDlaMiejscowosci has a boolean flag argument $asAddress, which is a certain sign of a Single Responsibility Principle violation. Open
public function PobierzListeUlicDlaMiejscowosci(int $tercId, string $cityId, bool $asAddress = false): array
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method request has a boolean flag argument $addDate, which is a certain sign of a Single Responsibility Principle violation. Open
public function request(string $method, array $args = [], bool $addDate = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '60', column '20'). Open
$doc = new \DOMDocument('1.0');
- 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 '82', column '55'). Open
$this->statusDate = $dataStanu ? (new \DateTime($dataStanu))->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();
}