JsonApi/Request/Params.php
The class Params has 16 fields. Consider redesigning Params to keep the number of fields under 15. Open
Open
class Params
{
const ASCENDING_ORDER = Criteria::ASC,
DESCENDING_ORDER = Criteria::DESC,
DEFAULT_PAGE_OFFSET = 0,
- Read upRead up
- Exclude checks
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
Open
public function getSortOrder($field, $relationship = NULL)
{
$sortedByRelationship = NULL;
if (empty($relationship)) {
- 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
TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" Open
Open
public function getSortOrder($field, $relationship = NULL)
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL" Open
Open
$sortedByRelationship = NULL;
- Exclude checks