Method processLinkedResources
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processLinkedResources(
ResourceCollectionInterface $resources,
array $include,
LinkedResourcesSerialization $resourcesSerialization,
$depth = 0
Method processToManyRelationship
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processToManyRelationship(
ResourceCollectionInterface $resources,
$relationshipName,
array &$linkedResources,
LinkedResourcesSerialization $resourcesSerialization
Method processToOneRelationship
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processToOneRelationship(
ResourceCollectionInterface $resources,
$relationshipName,
array &$linkedResources,
LinkedResourcesSerialization $resourcesSerialization
Function processLinkedResources
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function processLinkedResources(
ResourceCollectionInterface $resources,
array $include,
LinkedResourcesSerialization $resourcesSerialization,
$depth = 0
- 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 processToManyRelationship
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function processToManyRelationship(
ResourceCollectionInterface $resources,
$relationshipName,
array &$linkedResources,
LinkedResourcesSerialization $resourcesSerialization
- 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 processToOneRelationship
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function processToOneRelationship(
ResourceCollectionInterface $resources,
$relationshipName,
array &$linkedResources,
LinkedResourcesSerialization $resourcesSerialization
- 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
Avoid using undefined variables such as '$relationships' which will lead to PHP notices. Open
implode('.', $relationships)
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using static access to class '\GoIntegro\Hateoas\JsonApi\EntityResource' in method 'processToManyRelationship'. Open
= EntityResource::normalizeToManyRelation(
$collection, $relationshipName
);
- 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 processLinkedResources uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$message = sprintf(
self::ERROR_UNKOWN_RELATIONSHIP, $relationshipName
);
throw new InvalidRelationshipException($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
Avoid using static access to class '\GoIntegro\Hateoas\JsonApi\EntityResource' in method 'processToManyRelationship'. Open
EntityResource::getStringId($entity)
- 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
Avoid using static access to class '\GoIntegro\Hateoas\JsonApi\ResourceCollection' in method 'processLinkedResources'. Open
ResourceCollection::buildFromArray($linkedResources),
- 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
Avoid using static access to class '\GoIntegro\Hateoas\JsonApi\EntityResource' in method 'processToOneRelationship'. Open
EntityResource::validateToOneRelation(
$entity, $relationshipName
);
- 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 processToManyRelationship uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
// @todo This should never happen.
throw new SerializationException(sprintf(
self::ERROR_INHERITANCE_MAPPING,
implode('.', $relationships)
- 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 using static access to class '\GoIntegro\Hateoas\JsonApi\EntityResource' in method 'processToOneRelationship'. Open
EntityResource::getStringId($entity)
- 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
Avoid using static access to class '\GoIntegro\Hateoas\JsonApi\EntityResource' in method 'addLinkedResource'. Open
$relationship->type, EntityResource::getStringId($entity)
- 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
Avoid unused local variables such as '$relationships'. Open
implode('.', $relationships)
- 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 local variables such as '$relationOfRelation'. Open
$relationOfRelation = [];
- 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 excessively long variable names like $resourcesSerialization. Keep variable name length under 20. Open
$resourcesSerialization = new LinkedResourcesSerialization;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $resourcesSerialization. Keep variable name length under 20. Open
LinkedResourcesSerialization $resourcesSerialization,
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $resourcesSerialization. Keep variable name length under 20. Open
LinkedResourcesSerialization $resourcesSerialization
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $resourcesSerialization. Keep variable name length under 20. Open
LinkedResourcesSerialization $resourcesSerialization
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $resourcesSerialization. Keep variable name length under 20. Open
LinkedResourcesSerialization $resourcesSerialization
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
There must be one USE keyword per declaration Open
use GoIntegro\Hateoas\JsonApi\ResourceEntityInterface,
- 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
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$relationship->type, EntityResource::getStringId($entity)
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$entity, $relationshipName
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
self::ERROR_UNKOWN_RELATIONSHIP, $relationshipName
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$relationship, $entity, $resourcesSerialization
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$relationship, $entity, $resourcesSerialization
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
self::ERROR_UNKOWN_RELATIONSHIP, $relationshipName
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$resource, $this->securityContext, $fields
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
self::ERROR_UNKOWN_RELATIONSHIP, $relationshipName
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$resource, $this->securityContext, $fields
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$relationship, $entity, $resourcesSerialization
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$relationship, $entity, $resourcesSerialization
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$collection, $relationshipName
- Exclude checks
Line exceeds 120 characters; contains 159 characters Open
ERROR_LINK_ONLY_RELATIONSHIP = "The relationship \"%s\" cannot be included, possibly because of its size. You must fetch this resource by getting %s.",
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
ERROR_INHERITANCE_MAPPING = "The mapping inheritance in the ORM for the relationship \"%s\" is not being properly handled.",
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks