The class GeoAnalysisResult has 16 public methods. Consider refactoring GeoAnalysisResult to keep number of public methods under 10. Open
class GeoAnalysisResult
{
private string $description;
private int $order;
private int $unknown_count;
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The method sortedKnownPlaces has a boolean flag argument $exclude_other, which is a certain sign of a Single Responsibility Principle violation. Open
public function sortedKnownPlaces(bool $exclude_other = false): Collection
- 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 knownPlaces has a boolean flag argument $exclude_other, which is a certain sign of a Single Responsibility Principle violation. Open
public function knownPlaces(bool $exclude_other = false): Collection
- 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
Avoid using static access to class '\Fisharebest\Webtrees\I18N' in method 'sortedKnownPlaces'. Open
I18N::comparator()($a->place()->place()->gedcomName(), $b->place()->place()->gedcomName())
- 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
The method addPlace uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->addUnknown();
}
- 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
}
}
}