JsonApi/Serializer/TopLevelLinkedLinksSerializer.php
The method addResourceLinks uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$urlTemplate = $this->buildByRelationshipUrlTemplate(
$resource, $relationship
);
}
- 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
Open
{
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
Open
$walk = function($relationship) use (&$json, $resource) {
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
Open
{
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" Open
Open
$urlTemplate = NULL;
- Exclude checks
Multi-line function declarations must define one parameter per line Open
Open
EntityResource $resource, $relationshipName
- Exclude checks
Multi-line function declarations must define one parameter per line Open
Open
EntityResource $resource, ResourceRelationship $relationship
- Exclude checks
Multi-line function declarations must define one parameter per line Open
Open
EntityResource $resource, ResourceRelationship $relationship
- Exclude checks
Multi-line function declarations must define one parameter per line Open
Open
EntityResource $resource, ResourceRelationship $relationship
- Exclude checks
Multi-line function declarations must define one parameter per line Open
Open
EntityResource $resource, ResourceRelationship $relationship
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
Open
{
- Exclude checks
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line Open
Open
{
- Exclude checks
There must be one USE keyword per declaration Open
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
Open
{
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
Open
$resource, $relationship
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
Open
$resource, $relationship
- Exclude checks
Inline control structures are not allowed Open
Open
if (!$resource->getMetadata()->hasRelationships()) continue;
- Exclude checks
Line exceeds 120 characters; contains 179 characters Open
Open
const ERROR_MISSING_MAPPING_FIELD = "Una de las relaciones declaradas o evaluadas como \"link-only\" posiblemente no tenga un campo de mapeo inverso en la entidad vinculada.",
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
Open
if (
- Exclude checks