Function cast
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Wontfix
public static function cast(int $asType, $value)
{
// get the value type
$type = self::typeMask($value);
- 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 cast
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
public static function cast(int $asType, $value)
{
// get the value type
$type = self::typeMask($value);
Function typeMask
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Invalid
public static function typeMask($value, bool $onlyOne = false) : int
{
if (is_null($value)) {
return JsonBrowser::TYPE_NULL;
}
- 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 typeMask
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Invalid
public static function typeMask($value, bool $onlyOne = false) : int
{
if (is_null($value)) {
return JsonBrowser::TYPE_NULL;
}
Function compareObjects
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Wontfix
private static function compareObjects(\StdClass $valueOne, \StdClass $valueTwo)
{
foreach ($valueOne as $pName => $pValue) {
if (!property_exists($valueTwo, $pName) || !self::compare($valueOne->$pName, $valueTwo->$pName)) {
return false;
- 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 too many return
statements within this method. Invalid
return preg_split('//u', $value, null, \PREG_SPLIT_NO_EMPTY);
Avoid too many return
statements within this method. Invalid
return (int) $value;
Avoid too many return
statements within this method. Invalid
return [];
Avoid too many return
statements within this method. Wontfix
return false;
Avoid too many return
statements within this method. Invalid
return new \stdClass();
Avoid too many return
statements within this method. Wontfix
return JsonBrowser::TYPE_ARRAY;
Avoid too many return
statements within this method. Invalid
return (object) preg_split('//u', $value, null, \PREG_SPLIT_NO_EMPTY);
Avoid too many return
statements within this method. Invalid
return (bool) strlen($value);
Avoid too many return
statements within this method. Wontfix
return false;
Avoid too many return
statements within this method. Invalid
return 0;
Avoid too many return
statements within this method. Invalid
return $value != 0;
Avoid too many return
statements within this method. Wontfix
return JsonBrowser::TYPE_OBJECT;
Avoid too many return
statements within this method. Invalid
return (object) ['value' => $value];
Avoid too many return
statements within this method. Invalid
return [$value];
Avoid too many return
statements within this method. Invalid
return (object) ['value' => $value];
Avoid too many return
statements within this method. Invalid
return '';
Avoid too many return
statements within this method. Invalid
return json_encode($value);
Avoid too many return
statements within this method. Invalid
return json_encode($value);
Avoid too many return
statements within this method. Invalid
return mb_strlen($value);
Avoid too many return
statements within this method. Invalid
return [$value];
Avoid too many return
statements within this method. Invalid
return (int)$value;
Avoid too many return
statements within this method. Invalid
return (bool) count((array)$value);
Avoid too many return
statements within this method. Wontfix
return count((array)$value);
Avoid too many return
statements within this method. Invalid
return null;
Function compare
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Wontfix
public static function compare($valueOne, $valueTwo) : bool
{
// fast-path for type-equal (or instance-equal) values
if ($valueOne === $valueTwo) {
- 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"