Method serialize
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function serialize()
{
$metadata = $this->resource->getMetadata();
$json = [
'id' => $this->resource->id,
Function serialize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function serialize()
{
$metadata = $this->resource->getMetadata();
$json = [
'id' => $this->resource->id,
- 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
Method getResourceLinks
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getResourceLinks(EntityResource $resource)
{
$links = [];
foreach (
Function getResourceLinks
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function getResourceLinks(EntityResource $resource)
{
$links = [];
foreach (
- 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 unused parameters such as '$resource'. Open
private function getResourceLinks(EntityResource $resource)
- 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
Avoid using static access to class '\GoIntegro\Hateoas\JsonApi\EntityResource' in method 'getResourceLinks'. Open
$collection = EntityResource::normalizeToManyRelation(
$collection, $relationship
);
- 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 'getResourceLinks'. Open
EntityResource::validateToOneRelation($entity, $relationship);
- 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 'getResourceLinks'. Open
$links[$relationship][] = 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 'getResourceLinks'. Open
) ? EntityResource::getStringId($entity) : NULL;
- 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
Space found before closing bracket of FOREACH loop Open
foreach (
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" Open
) ? EntityResource::getStringId($entity) : NULL;
- Exclude checks
Expected 1 space before "as"; 16 found Open
foreach (
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
{
- Exclude checks
Space found after opening bracket of FOREACH loop Open
foreach (
- Exclude checks
Expected 1 space before "as"; 16 found Open
foreach (
- Exclude checks
Space found before closing bracket of FOREACH loop Open
foreach (
- Exclude checks
Space found after opening bracket of FOREACH loop Open
foreach (
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$field, $this->resource, $message
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$field, $this->resource, $message
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$collection, $relationship
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$field, $this->resource, $message
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$field, $this->resource, $message
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
static::ACCESS_VIEW, $entity
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$field, $this->resource, $message
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
$field, $this->resource, $message
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
static::ACCESS_VIEW, $entity
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
foreach (
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
foreach (
- Exclude checks