Function mergeLinkedResources
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function mergeLinkedResources(array &$champion, array $challenger)
{
static $key = 'linked';
if (isset($champion[$key]) || isset($challenger[$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 mergeResourceMeta
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function mergeResourceMeta(array &$champion, array $challenger)
{
static $key = 'meta';
if (isset($champion[$key]) || isset($challenger[$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 mergeTopLevelLinks
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function mergeTopLevelLinks(array &$champion, array $challenger)
{
static $key = 'links';
if (isset($champion[$key]) || isset($challenger[$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 mergePrimaryResources
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function mergePrimaryResources(array &$champion, array $challenger)
{
foreach ($challenger as $key => $value) {
if (in_array($key, static::$reservedTopLevel)) continue;
- 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
Missing class import via use statement (line '67', column '31'). Open
throw new \LogicException(
- 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
The method mergeLinkedResources uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$champion[$key][$type] = $collection;
}
- 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 mergeResourceMeta uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new UnmergeableResourcesException;
}
- 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 resolveResourceObject uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new UnmergeableResourcesException;
}
- 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 resolveSameType uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new UnmergeableResourcesException;
}
- 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 mergeTopLevelLinks uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$champion[$key] = $links;
}
- 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 closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
$callback = function(array $resource) use (&$byIds) {
- Exclude checks
Multi-line function declarations must define one parameter per line Open
array $resourceA, array $resourceB
- Exclude checks
Multi-line function declarations must define one parameter per line Open
array $resourceA, array $resourceB
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
Multi-line function declarations must define one parameter per line Open
array $collectionA, array $collectionB
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
$compare = function(array $linkA, array $linkB) {
- Exclude checks
Multi-line function declarations must define one parameter per line Open
array $resourceA, array $resourceB
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$champion[$key], $links, $compare
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$champion[$key], $links, $compare
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$champion[$key][$type], $collection
- Exclude checks
Inline control structures are not allowed Open
if (in_array($key, static::$reservedTopLevel)) continue;
- Exclude checks
Line exceeds 120 characters; contains 178 characters Open
const ERROR_MISSING_TOP_LEVEL_LINKS = "Por algún motivo desconocido dos recursos del mismo tipo intentan registrar dos plantillas de URL distintas para la misma relación.";
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
} elseif (
- Exclude checks