SlotRecord
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class SlotRecord {
use NonSerializableTrait;
public const MAIN = 'main';
File SlotRecord.php
has 293 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Value object representing a content slot associated with a page revision.
*
* This program is free software; you can redistribute it and/or modify
Method newSaved
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function newSaved(
int $revisionId,
?int $contentId,
string $contentAddress,
SlotRecord $protoSlot
Method __construct
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( \stdClass $row, $content, bool $derived = false ) {
Assert::parameterType( [ 'Content', 'callable' ], $content, '$content' );
Assert::parameter(
property_exists( $row, 'slot_revision_id' ),
Function newSaved
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function newSaved(
int $revisionId,
?int $contentId,
string $contentAddress,
SlotRecord $protoSlot
- 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. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Function getField
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function getField( $name ) {
if ( !isset( $this->row->$name ) ) {
// distinguish between unknown and uninitialized fields
if ( property_exists( $this->row, $name ) ) {
throw new IncompleteRevisionException(
- 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 hasSameContent
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function hasSameContent( SlotRecord $other ) {
if ( $other === $this ) {
return true;
}
- 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"