The class SettingsManager has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13. Open
class SettingsManager implements SettingsManagerInterface
{
protected ?AccessUrl $url = null;
protected ServiceRegistryInterface $schemaRegistry;
- 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
The method load uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
return $settings;
}
- 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 getParametersFromKeyword uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$query = $this->repository->createQueryBuilder('s')
->where('s.variable LIKE :keyword')
->setParameter('keyword', "%{$keyword}%")
;
- 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 loadAll uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$knownParameters[$parameter] = $transformer->reverseTransform($knownParameters[$parameter]);
}
- 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 update uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$parameter = (new SettingsCurrent())
->setVariable($name)
->setCategory($simpleCategoryName)
->setTitle($name)
- 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 load uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$parameters[$parameter] = $transformer->reverseTransform($parameters[$parameter]);
}
- 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 validateSetting uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$message = \sprintf('Parameter must be in format "category.name", "%s" given.', $name);
throw new InvalidArgumentException($message);
}
- 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 save uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$parameter = (new SettingsCurrent())
->setVariable($name)
->setCategory($simpleCategoryName)
->setTitle($name)
- 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
Avoid unused local variables such as '$value'. Open
foreach ($parameters as $name => $value) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused parameters such as '$namespace'. Open
public function load(string $schemaAlias, ?string $namespace = null, bool $ignoreUnknown = true): SettingsInterface
- 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
Missing function doc comment Open
public function getUrl(): ?AccessUrl
- Exclude checks
Space before opening parenthesis of function call prohibited Open
fn ($key): bool => $settingsBuilder->isDefined($key),
- Exclude checks
Add a single space around assignment operators Open
declare(strict_types=1);
- Exclude checks
Missing function doc comment Open
public function updateSchemas(AccessUrl $url): void
- Exclude checks
Missing function doc comment Open
public function setUrl(AccessUrl $url): void
- Exclude checks
Missing function doc comment Open
public function loadAll(): void
- Exclude checks
Missing function doc comment Open
public function __construct(
- Exclude checks
Missing function doc comment Open
public function updateSetting(string $name, $value): void
- Exclude checks
Missing function doc comment Open
public function installSchemas(AccessUrl $url): void
- Exclude checks
Missing function doc comment Open
public function convertServiceToNameSpace(string $category): string
- Exclude checks
Missing function doc comment Open
public function convertNameSpaceToService(string $category): string
- Exclude checks
Missing function doc comment Open
public function load(string $schemaAlias, ?string $namespace = null, bool $ignoreUnknown = true): SettingsInterface
- Exclude checks
Missing function doc comment Open
public function update(SettingsInterface $settings): void
- Exclude checks
Space before opening parenthesis of function call prohibited Open
fn ($key): bool => $settingsBuilder->isDefined($key),
- Exclude checks