edde-framework/edde-framework

View on GitHub
src/Edde/Common/Node/NodeUtils.php

Summary

Maintainability
D
1 day
Test Coverage

Function toNode has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

        static public function toNode(\stdClass $stdClass, INode $node = null, string $class = null): INode {
            $createNode = function (string $class, string $name = null): INode {
                /** @var $node INode */
                if (($node = new $class()) instanceof INode === false) {
                    throw new ClassMismatchException(sprintf('Class specified [%s] is not instance of [%s].', $class, INode::class));
Severity: Minor
Found in src/Edde/Common/Node/NodeUtils.php - About 6 hrs to fix

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 node has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

        static public function node(INode $root, $source): INode {
            $callback = null;
            if (is_array($source) === false && is_object($source) === false) {
                throw new NodeException('Source must be array or stdClass object.');
            }
Severity: Minor
Found in src/Edde/Common/Node/NodeUtils.php - About 4 hrs to fix

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 node has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        static public function node(INode $root, $source): INode {
            $callback = null;
            if (is_array($source) === false && is_object($source) === false) {
                throw new NodeException('Source must be array or stdClass object.');
            }
Severity: Major
Found in src/Edde/Common/Node/NodeUtils.php - About 2 hrs to fix

Method toNode has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        static public function toNode(\stdClass $stdClass, INode $node = null, string $class = null): INode {
            $createNode = function (string $class, string $name = null): INode {
                /** @var $node INode */
                if (($node = new $class()) instanceof INode === false) {
                    throw new ClassMismatchException(sprintf('Class specified [%s] is not instance of [%s].', $class, INode::class));
Severity: Minor
Found in src/Edde/Common/Node/NodeUtils.php - About 1 hr to fix

Function fromNode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        static public function fromNode(INode $root): \stdClass {
            $object = new \stdClass();
            $attributeList = $root->getAttributeList();
            if (($value = $root->getValue()) !== null) {
                $object->{'::value'} = $value;
Severity: Minor
Found in src/Edde/Common/Node/NodeUtils.php - About 25 mins to fix

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 namespace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        static public function namespace(INode $root, string $preg) {
            foreach (NodeIterator::recursive($root, true) as $node) {
                $attributeList = $node->getAttributeList();
                foreach ($attributeList as $k => $value) {
                    if (($match = StringUtils::match($k, $preg, true)) !== null) {
Severity: Minor
Found in src/Edde/Common/Node/NodeUtils.php - About 25 mins to fix

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

There are no issues that match your filters.

Category
Status