bnomei/kirby3-php-cachedriver

View on GitHub

Showing 10 of 10 total issues

File PHPCache.php has 313 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Bnomei;
Severity: Minor
Found in classes/PHPCache.php - About 3 hrs to fix

    Function benchmark has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public function benchmark(int $count = 10)
        {
            $prefix = "elephant-benchmark-";
            $php = $this;
            $file = kirby()->cache('bnomei.php-cachedriver'); // neat, right? ;-)
    Severity: Minor
    Found in classes/PHPCache.php - About 3 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

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

    final class PHPCache extends FileCache
    {
        private $shutdownCallbacks = [];
    
        /** @var array $database */
    Severity: Minor
    Found in classes/PHPCache.php - About 2 hrs to fix

      Method benchmark has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function benchmark(int $count = 10)
          {
              $prefix = "elephant-benchmark-";
              $php = $this;
              $file = kirby()->cache('bnomei.php-cachedriver'); // neat, right? ;-)
      Severity: Minor
      Found in classes/PHPCache.php - About 1 hr to fix

        Method setOptions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function setOptions(array $options)
            {
                $root = null;
                $cache = kirby()->cache('bnomei.php-cachedriver');
                if (is_a($cache, FileCache::class)) {
        Severity: Minor
        Found in classes/PHPCache.php - About 1 hr to fix

          Function setOptions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function setOptions(array $options)
              {
                  $root = null;
                  $cache = kirby()->cache('bnomei.php-cachedriver');
                  if (is_a($cache, FileCache::class)) {
          Severity: Minor
          Found in classes/PHPCache.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 load has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function load()
              {
                  $this->database = [];
          
                  $monoFile = $this->file(static::DB_FILENAME);
          Severity: Minor
          Found in classes/PHPCache.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 removeAndSet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function removeAndSet(string $key, $value, int $minutes = 0): bool
              {
                  $this->remove($key);
          
                  $key = $this->key($key);
          Severity: Minor
          Found in classes/PHPCache.php - About 35 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 garbagecollect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function garbagecollect(): bool
              {
                  $count = 0;
                  foreach (array_keys($this->database) as $key) {
                      $expires = null;
          Severity: Minor
          Found in classes/PHPCache.php - About 35 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 serialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function serialize($value)
              {
                  if (! $value) {
                      return null;
                  }
          Severity: Minor
          Found in classes/PHPCache.php - About 35 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

          Severity
          Category
          Status
          Source
          Language