skqr/hateoas

View on GitHub
JsonApi/Request/Params.php

Summary

Maintainability
A
45 mins
Test Coverage

The class Params has 16 fields. Consider redesigning Params to keep the number of fields under 15.
Open

class Params
{
    const ASCENDING_ORDER = Criteria::ASC,
        DESCENDING_ORDER = Criteria::DESC,
        DEFAULT_PAGE_OFFSET = 0,
Severity: Minor
Found in JsonApi/Request/Params.php by phpmd

TooManyFields

Since: 0.1

Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

Example

class Person {
   protected $one;
   private $two;
   private $three;
   [... many more fields ...]
}

Source https://phpmd.org/rules/codesize.html#toomanyfields

Function getSortOrder has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSortOrder($field, $relationship = NULL)
    {
        $sortedByRelationship = NULL;

        if (empty($relationship)) {
Severity: Minor
Found in JsonApi/Request/Params.php - About 45 mins to fix

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

TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL"
Open

    public function getSortOrder($field, $relationship = NULL)
Severity: Minor
Found in JsonApi/Request/Params.php by phpcodesniffer

TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL"
Open

        $sortedByRelationship = NULL;
Severity: Minor
Found in JsonApi/Request/Params.php by phpcodesniffer

There are no issues that match your filters.

Category
Status