symplely/coroutine

View on GitHub
Coroutine/Logger/Logger.php

Summary

Maintainability
D
1 day
Test Coverage

File Logger.php has 355 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Async;
Severity: Minor
Found in Coroutine/Logger/Logger.php - About 4 hrs to fix

    Logger has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    final class Logger extends AsyncLogger implements AsyncLoggerInterface
    {
      private static $levels = [
        self::DEBUG     => LogLevel::DEBUG,
        self::INFO      => LogLevel::INFO,
    Severity: Minor
    Found in Coroutine/Logger/Logger.php - About 3 hrs to fix

      Function interpolate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        private static function interpolate($string, array $vars)
        {
          if (!\preg_match_all("~\{([\w\.]+)\}~", $string, $matches, \PREG_SET_ORDER)) {
            return $string;
          }
      Severity: Minor
      Found in Coroutine/Logger/Logger.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 setWriter has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        public function setWriter(callable $writer = null, $levels = self::ALL, $interval = 1, callable $formatter = null)
        {
          if (empty($formatter)) {
            $formatter = $this->defaultFormatter;
          }
      Severity: Minor
      Found in Coroutine/Logger/Logger.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 setWriter has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public function setWriter(callable $writer = null, $levels = self::ALL, $interval = 1, callable $formatter = null)
        {
          if (empty($formatter)) {
            $formatter = $this->defaultFormatter;
          }
      Severity: Minor
      Found in Coroutine/Logger/Logger.php - About 1 hr to fix

        Method interpolate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private static function interpolate($string, array $vars)
          {
            if (!\preg_match_all("~\{([\w\.]+)\}~", $string, $matches, \PREG_SET_ORDER)) {
              return $string;
            }
        Severity: Minor
        Found in Coroutine/Logger/Logger.php - About 1 hr to fix

          Method mailWriter has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              $to,
              $subject = null,
              array $headers = [],
              $levels = self::ALL,
              $interval = 1,
          Severity: Minor
          Found in Coroutine/Logger/Logger.php - About 45 mins to fix

            Function log has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              public function log($level, $message, array $context = [])
              {
                if (false === $level = \array_search($level, self::$levels, true)) {
                  yield $this->close();
                  throw new InvalidArgumentException(\sprintf("Unknown logger(%s) level name: '%s'", $this->name, $level));
            Severity: Minor
            Found in Coroutine/Logger/Logger.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

            There are no issues that match your filters.

            Category
            Status