Country
has 79 functions (exceeds 20 allowed). Consider refactoring. Open
class Country
{
/**
* The attributes array.
*
- Create a ticketCreate a ticket
File Country.php
has 387 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Rinvex\Country;
- Create a ticketCreate a ticket
The class Country has an overall complexity of 121 which is very high. The configured complexity threshold is 50. Open
class Country
{
/**
* The attributes array.
*
- Create a ticketCreate a ticket
- Exclude checks
The class Country has 79 public methods and attributes. Consider reducing the number of public items to less than 45. Open
class Country
{
/**
* The attributes array.
*
- Read upRead up
- Create a ticketCreate a ticket
- 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
Consider simplifying this complex logical expression. Open
if (empty($this->getName()) || empty($this->getOfficialName())
|| empty($this->getNativeName()) || empty($this->getNativeOfficialName())
|| empty($this->getIsoAlpha2()) || empty($this->getIsoAlpha3())) {
throw new Exception('Missing mandatory country attributes!');
}
- Create a ticketCreate a ticket
Function get
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get($key, $default = null)
{
$array = $this->attributes;
if (is_null($key)) {
- Read upRead up
- Create a ticketCreate a ticket
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 assigning values to variables in if clauses and the like (line '867', column '16'). Open
public function getDivisions(): ?array
{
if (! ($code = $this->getIsoAlpha2())) {
return null;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '894', column '16'). Open
public function getTimezones()
{
if (! ($code = $this->getIsoAlpha2())) {
return;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '839', column '16'). Open
public function getGeoJson(): ?string
{
if (! ($code = $this->getIsoAlpha2())) {
return null;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '908', column '16'). Open
public function getLocales()
{
if (! ($code = $this->getIsoAlpha2())) {
return;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '853', column '16'). Open
public function getFlag(): ?string
{
if (! ($code = $this->getIsoAlpha2())) {
return null;
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}