chdemko/php-sorted-collections

View on GitHub
src/SortedCollection/SubMap.php

Summary

Maintainability
F
5 days
Test Coverage

File SubMap.php has 462 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * chdemko\SortedCollection\SubMap class
 *
Severity: Minor
Found in src/SortedCollection/SubMap.php - About 7 hrs to fix

    SubMap has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SubMap extends AbstractMap
    {
        /**
         * When the from or to key is unused
         *
    Severity: Minor
    Found in src/SortedCollection/SubMap.php - About 2 hrs to fix

      Function lower has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function lower($key)
          {
              if ($this->empty) {
                  throw new \OutOfBoundsException('Lower element unexisting');
              }
      Severity: Minor
      Found in src/SortedCollection/SubMap.php - About 2 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 ceiling has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function ceiling($key)
          {
              if ($this->empty) {
                  throw new \OutOfBoundsException('Ceiling element unexisting');
              }
      Severity: Minor
      Found in src/SortedCollection/SubMap.php - About 2 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 higher has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function higher($key)
          {
              if ($this->empty) {
                  throw new \OutOfBoundsException('Higher element unexisting');
              }
      Severity: Minor
      Found in src/SortedCollection/SubMap.php - About 2 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 floor has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function floor($key)
          {
              if ($this->empty) {
                  throw new \OutOfBoundsException('Floor element unexisting');
              }
      Severity: Minor
      Found in src/SortedCollection/SubMap.php - About 2 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 floor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function floor($key)
          {
              if ($this->empty) {
                  throw new \OutOfBoundsException('Floor element unexisting');
              }
      Severity: Minor
      Found in src/SortedCollection/SubMap.php - About 1 hr to fix

        Method ceiling has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function ceiling($key)
            {
                if ($this->empty) {
                    throw new \OutOfBoundsException('Ceiling element unexisting');
                }
        Severity: Minor
        Found in src/SortedCollection/SubMap.php - About 1 hr to fix

          Method jsonSerialize has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function jsonSerialize(): array
              {
                  if ($this->fromOption == self::UNUSED) {
                      if ($this->toOption == self::UNUSED) {
                          return array(
          Severity: Minor
          Found in src/SortedCollection/SubMap.php - About 1 hr to fix

            Method lower has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function lower($key)
                {
                    if ($this->empty) {
                        throw new \OutOfBoundsException('Lower element unexisting');
                    }
            Severity: Minor
            Found in src/SortedCollection/SubMap.php - About 1 hr to fix

              Method higher has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function higher($key)
                  {
                      if ($this->empty) {
                          throw new \OutOfBoundsException('Higher element unexisting');
                      }
              Severity: Minor
              Found in src/SortedCollection/SubMap.php - About 1 hr to fix

                Function __set has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function __set($property, $value)
                    {
                        switch ($property) {
                            case 'fromKey':
                                $this->fromKey = $value;
                Severity: Minor
                Found in src/SortedCollection/SubMap.php - About 1 hr 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 __set has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function __set($property, $value)
                    {
                        switch ($property) {
                            case 'fromKey':
                                $this->fromKey = $value;
                Severity: Minor
                Found in src/SortedCollection/SubMap.php - About 1 hr to fix

                  Method __get has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function __get($property)
                      {
                          switch ($property) {
                              case 'fromKey':
                                  if ($this->fromOption == self::UNUSED) {
                  Severity: Minor
                  Found in src/SortedCollection/SubMap.php - About 1 hr to fix

                    Function find has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function find($key)
                        {
                            switch ($this->fromOption) {
                                case self::INCLUSIVE:
                                    if (call_user_func($this->map->comparator(), $key, $this->fromKey) < 0) {
                    Severity: Minor
                    Found in src/SortedCollection/SubMap.php - About 1 hr 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 __get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function __get($property)
                        {
                            switch ($property) {
                                case 'fromKey':
                                    if ($this->fromOption == self::UNUSED) {
                    Severity: Minor
                    Found in src/SortedCollection/SubMap.php - About 55 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 successor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function successor($element)
                        {
                            $successor = $this->map->successor($element);
                    
                            if ($successor) {
                    Severity: Minor
                    Found in src/SortedCollection/SubMap.php - About 45 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 jsonSerialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function jsonSerialize(): array
                        {
                            if ($this->fromOption == self::UNUSED) {
                                if ($this->toOption == self::UNUSED) {
                                    return array(
                    Severity: Minor
                    Found in src/SortedCollection/SubMap.php - About 45 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 predecessor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function predecessor($element)
                        {
                            $predecessor = $this->map->predecessor($element);
                    
                            if ($predecessor) {
                    Severity: Minor
                    Found in src/SortedCollection/SubMap.php - About 45 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

                    Method create has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public static function create(SortedMap $map, $fromKey, $toKey, $fromInclusive = true, $toInclusive = false)
                    Severity: Minor
                    Found in src/SortedCollection/SubMap.php - About 35 mins to fix

                      Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          protected function __construct(SortedMap $map, $fromKey, $fromOption, $toKey, $toOption)
                      Severity: Minor
                      Found in src/SortedCollection/SubMap.php - About 35 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $this->map;
                        Severity: Major
                        Found in src/SortedCollection/SubMap.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return parent::__get($property);
                          Severity: Major
                          Found in src/SortedCollection/SubMap.php - About 30 mins to fix

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

                                protected function setEmpty()
                                {
                                    if ($this->fromOption != self::UNUSED && $this->toOption != self::UNUSED) {
                                        $cmp = call_user_func($this->map->comparator(), $this->fromKey, $this->toKey);
                            
                            
                            Severity: Minor
                            Found in src/SortedCollection/SubMap.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

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                    if ($ceiling) {
                                        switch ($this->fromOption) {
                                            case self::INCLUSIVE:
                                                if (call_user_func($this->map->comparator(), $ceiling->key, $this->fromKey) < 0) {
                                                      $ceiling = $this->first();
                            Severity: Major
                            Found in src/SortedCollection/SubMap.php and 1 other location - About 1 hr to fix
                            src/SortedCollection/SubMap.php on lines 747..760

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 109.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                    if ($lower) {
                                        switch ($this->toOption) {
                                            case self::INCLUSIVE:
                                                if (call_user_func($this->map->comparator(), $lower->key, $this->toKey) > 0) {
                                                      $lower = $this->last();
                            Severity: Major
                            Found in src/SortedCollection/SubMap.php and 1 other location - About 1 hr to fix
                            src/SortedCollection/SubMap.php on lines 595..608

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 109.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                    if ($floor) {
                                        switch ($this->toOption) {
                                            case self::INCLUSIVE:
                                                if (call_user_func($this->map->comparator(), $floor->key, $this->toKey) > 0) {
                                                      $floor = $this->last();
                            Severity: Major
                            Found in src/SortedCollection/SubMap.php and 1 other location - About 1 hr to fix
                            src/SortedCollection/SubMap.php on lines 540..553

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 109.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                    if ($higher) {
                                        switch ($this->fromOption) {
                                            case self::INCLUSIVE:
                                                if (call_user_func($this->map->comparator(), $higher->key, $this->fromKey) < 0) {
                                                      $higher = $this->first();
                            Severity: Major
                            Found in src/SortedCollection/SubMap.php and 1 other location - About 1 hr to fix
                            src/SortedCollection/SubMap.php on lines 692..705

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 109.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                public function last()
                                {
                                    if ($this->empty) {
                                        throw new \OutOfBoundsException('Last element unexisting');
                                    }
                            Severity: Minor
                            Found in src/SortedCollection/SubMap.php and 1 other location - About 45 mins to fix
                            src/SortedCollection/SubMap.php on lines 386..405

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 95.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                public function first()
                                {
                                    if ($this->empty) {
                                        throw new \OutOfBoundsException('First element unexisting');
                                    }
                            Severity: Minor
                            Found in src/SortedCollection/SubMap.php and 1 other location - About 45 mins to fix
                            src/SortedCollection/SubMap.php on lines 416..435

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 95.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            There are no issues that match your filters.

                            Category
                            Status