Function detectNonSerializableDataInternal
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function detectNonSerializableDataInternal(
$value,
bool $expectDeserialize,
string $accumulatedPath,
bool $exhaustive = 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
Function serializeOne
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function serializeOne( &$value ) {
if ( $value instanceof JsonSerializable ) {
$value = $value->jsonSerialize();
if ( !is_array( $value ) ) {
// Although JsonSerializable doesn't /require/ the result to be
- 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
Function deserialize
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function deserialize( $json, string $expectedClass = null ) {
Assert::parameterType( [ 'stdClass', 'array', 'string' ], $json, '$json' );
Assert::precondition(
!$expectedClass || is_subclass_of( $expectedClass, JsonDeserializable::class ),
'$expectedClass parameter must be subclass of JsonDeserializable, got ' . $expectedClass
- 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 deserialize
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function deserialize( $json, string $expectedClass = null ) {
Assert::parameterType( [ 'stdClass', 'array', 'string' ], $json, '$json' );
Assert::precondition(
!$expectedClass || is_subclass_of( $expectedClass, JsonDeserializable::class ),
'$expectedClass parameter must be subclass of JsonDeserializable, got ' . $expectedClass
Method detectNonSerializableDataInternal
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function detectNonSerializableDataInternal(
$value,
bool $expectDeserialize,
string $accumulatedPath,
bool $exhaustive = false
Method serializeOne
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function serializeOne( &$value ) {
if ( $value instanceof JsonSerializable ) {
$value = $value->jsonSerialize();
if ( !is_array( $value ) ) {
// Although JsonSerializable doesn't /require/ the result to be
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return $propValueNonSerializablePath;
Avoid too many return
statements within this method. Open
return $accumulatedPath . ': nonscalar ' . get_debug_type( $value );
Function deserializeArray
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function deserializeArray( array $array ): array {
$deserializedExtensionData = [];
foreach ( $array as $key => $value ) {
if ( $key === JsonConstants::COMPLEX_ANNOTATION ) {
/* don't include this in the result */
- 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"