Showing 12 of 12 total issues
Function on
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
function on(string $eventName, /*mixed*/ $callBack, int $priority = 100)
{
if(!is_callable($callBack)) {
error_log("callback is not callable");
}
- 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 on
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function on(string $eventName, /*mixed*/ $callBack, int $priority = 100)
{
if(!is_callable($callBack)) {
error_log("callback is not callable");
}
Function add
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function add(NodeInterface $node, bool $skip_signals = false, $active_exceptions = false): NodeInterface
{
if($this->contains($node->id())) {
if($active_exceptions)
throw new Exceptions\NodeAlreadyMemberException($node, $this);
- 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 resolvePredicate
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function resolvePredicate(?PredicateInterface $predicate, string $fallback): PredicateInterface
{
$is_a_predicate = function(string $class_name): bool
{
if(!class_exists($class_name))
- 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 add
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add(NodeInterface $node, bool $skip_signals = false, $active_exceptions = false): NodeInterface
{
if($this->contains($node->id())) {
if($active_exceptions)
throw new Exceptions\NodeAlreadyMemberException($node, $this);
Method __construct
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(NodeInterface $tail, ?NodeInterface $head = null, ?PredicateInterface $predicate = null)
{
$this->predicate = $this->resolvePredicate($predicate, Predicate::class);
if( !$this->predicate->multiplicable()
Avoid too many return
statements within this method. Open
return new $fallback;
Avoid too many return
statements within this method. Open
return new \ArrayIterator(
array_map($hydrate, $this->$key[(string) $node_id])
);
Avoid too many return
statements within this method. Open
return new Predicate();
Avoid too many return
statements within this method. Open
return new \ArrayIterator(
array_map($hydrate, array_filter($this->$key[(string) $node_id], $filter_classes))
);
Avoid too many return
statements within this method. Open
return new \ArrayIterator(
array_map($hydrate,
array_filter($this->$d, $filter_classes)
)
);
Function remove
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function remove(ID $node_id): void
{
if($this->contains($node_id)) {
unset($this->nodes[(string) $node_id]);
unset($this->node_ids[array_search((string)$node_id, $this->node_ids)]);
- 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"