Showing 12 of 12 total issues
Function toDatabase
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
public function toDatabase(DBInterface $db, $tb, array $fields = [], bool $transaction = true): array
{
$cur = [];
$new = [];
$mod = [];
- 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 toDatabase
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toDatabase(DBInterface $db, $tb, array $fields = [], bool $transaction = true): array
{
$cur = [];
$new = [];
$mod = [];
Node
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class Node
{
public static function copy(Node $original): Node
{
$node = clone $original;
Function fromDatabase
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static function fromDatabase(DBInterface $db, $tb, array $fields = [], int $root = null): self
{
$lft = null;
$rgt = null;
$lvl = 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
File Tree.php
has 290 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace vakata\phptree;
use vakata\database\DBInterface;
Method fromDatabase
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function fromDatabase(DBInterface $db, $tb, array $fields = [], int $root = null): self
{
$lft = null;
$rgt = null;
$lvl = null;
Consider simplifying this complex logical expression. Open
if ($kk == 'parent' && $v[$vv] == null) {
$v[$vv] = null;
} elseif ($kk == 'parent' && isset($root) && (int)$v[$fields['id']] === $root) {
$v[$vv] = null;
} elseif ($kk == 'position' && isset($root) && (int)$v[$fields['id']] === $root) {
Function fromAdjacencyArray
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function fromAdjacencyArray(
array $nodes = [],
string $id = 'id',
string $parent = 'parent',
string $position = 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 fromAdjacencyArray
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function fromAdjacencyArray(
array $nodes = [],
string $id = 'id',
string $parent = 'parent',
string $position = null,
Method fromNestedSetArray
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function fromNestedSetArray(
array $nodes = [],
string $id = 'id',
string $left = 'left',
string $right = 'right'
Method fromAdjacencyArray
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
array $nodes = [],
string $id = 'id',
string $parent = 'parent',
string $position = null,
int $rootID = null
Function fromNestedSetArray
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function fromNestedSetArray(
array $nodes = [],
string $id = 'id',
string $left = 'left',
string $right = 'right'
- 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"