The class Tree has 15 public methods. Consider refactoring Tree to keep number of public methods under 10.
class Tree extends Node
{
public $root;
/**
Function remove
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
public function remove(IntervalInterface $i)
{
if (!$i->left && !$i->right) {
if ($i->root) {
$i->root = null;
Method remove
has 34 lines of code (exceeds 25 allowed). Consider refactoring.
public function remove(IntervalInterface $i)
{
if (!$i->left && !$i->right) {
if ($i->root) {
$i->root = null;
The method remove() has an NPath complexity of 384. The configured NPath complexity threshold is 200.
public function remove(IntervalInterface $i)
{
if (!$i->left && !$i->right) {
if ($i->root) {
$i->root = null;
The method remove() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
public function remove(IntervalInterface $i)
{
if (!$i->left && !$i->right) {
if ($i->root) {
$i->root = null;
The method __construct has a boolean flag argument $preSorted, which is a certain sign of a Single Responsibility Principle violation.
public function __construct(array $intervals = [], bool $preSorted = false)
The method remove uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
$this->left = new Node($i);
}
The method remove uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
$this->right = new Node($i);
}
The method remove uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
$this->max = $i->getEnd();
if ($this->right) {
$this->right->add($i);
} else {
Identical blocks of code found in 2 locations. Consider refactoring.
if ($this->max > $i->getEnd()) {
if ($this->left) {
$this->left->add($i);
} else {
$this->left = new Node($i);
Avoid variables with short names like $i. Configured minimum length is 3.
usort($arr, function (IntervalInterface $i0, IntervalInterface $i) {
Avoid variables with short names like $i. Configured minimum length is 3.
!$preSorted && usort($intervals, function (IntervalInterface $i0, IntervalInterface $i) {
Avoid variables with short names like $i0. Configured minimum length is 3.
!$preSorted && usort($intervals, function (IntervalInterface $i0, IntervalInterface $i) {
Avoid variables with short names like $i. Configured minimum length is 3.
public function remove(IntervalInterface $i)
Avoid variables with short names like $i. Configured minimum length is 3.
public function add(IntervalInterface $i)
Avoid variables with short names like $i0. Configured minimum length is 3.
usort($arr, function (IntervalInterface $i0, IntervalInterface $i) {
Avoid variables with short names like $el. Configured minimum length is 3.
array_walk($intervals, function (IntervalInterface $el) use (&$max) {
The variable $l_intervals is not named in camelCase.
public function toTree(array $intervals)
{
$max = 0;
$len = count($intervals);
$mid = (int) floor($len / 2);
The variable $r_intervals is not named in camelCase.
public function toTree(array $intervals)
{
$max = 0;
$len = count($intervals);
$mid = (int) floor($len / 2);
The variable $l_intervals is not named in camelCase.
public function toTree(array $intervals)
{
$max = 0;
$len = count($intervals);
$mid = (int) floor($len / 2);
The variable $r_intervals is not named in camelCase.
public function toTree(array $intervals)
{
$max = 0;
$len = count($intervals);
$mid = (int) floor($len / 2);
The variable $l_intervals is not named in camelCase.
public function toTree(array $intervals)
{
$max = 0;
$len = count($intervals);
$mid = (int) floor($len / 2);
The variable $r_intervals is not named in camelCase.
public function toTree(array $intervals)
{
$max = 0;
$len = count($intervals);
$mid = (int) floor($len / 2);
There are no issues that match your filters.