biurad/php-events-bus

View on GitHub

Showing 13 of 13 total issues

Function postProcess has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    private function postProcess(string $eventName): void
    {
        unset($this->wrappedListeners[$eventName]);
        $skipped = false;

Severity: Minor
Found in src/TraceableEventDispatcher.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 getNotCalledListeners has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function getNotCalledListeners(): array
    {
        try {
            $allListeners = $this->getListeners();
        } catch (\Exception $e) {
Severity: Minor
Found in src/TraceableEventDispatcher.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 postProcess has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function postProcess(string $eventName): void
    {
        unset($this->wrappedListeners[$eventName]);
        $skipped = false;

Severity: Minor
Found in src/TraceableEventDispatcher.php - About 1 hr to fix

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

        public function getNotCalledListeners(): array
        {
            try {
                $allListeners = $this->getListeners();
            } catch (\Exception $e) {
    Severity: Minor
    Found in src/TraceableEventDispatcher.php - About 1 hr to fix

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

          public function removeListener(string $eventName, $listener)
          {
              if (isset($this->wrappedListeners[$eventName])) {
                  foreach ($this->wrappedListeners[$eventName] as $index => $wrappedListener) {
                      if ($wrappedListener->getWrappedListener() === $listener) {
      Severity: Minor
      Found in src/TraceableEventDispatcher.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 __invoke has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __invoke(Event $event, string $eventName, EventDispatcherInterface $dispatcher): void
          {
              $dispatcher = $this->dispatcher ?? $dispatcher;
      
              $this->called   = true;
      Severity: Minor
      Found in src/WrappedListener.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 callListeners has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function callListeners(iterable $listeners, string $eventName, object $event): void
          {
              foreach ($listeners as $listener) {
                  if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
                      break;
      Severity: Minor
      Found in src/LazyEventDispatcher.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

      Avoid too many return statements within this method.
      Open

                  return -1;
      Severity: Major
      Found in src/TraceableEventDispatcher.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return 1;
        Severity: Major
        Found in src/TraceableEventDispatcher.php - About 30 mins to fix

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

              public function __construct($data = null, string $event = null, int $priority = 0)
              {
                  if (is_array($data) && isset($data['value'])) {
                      $data['event'] = $data['value'];
                      unset($data['value']);
          Severity: Minor
          Found in src/Annotation/Listener.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

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

              public function getListenerPriority(string $eventName, $listener)
              {
                  // we might have wrapped listeners for the event (if called while dispatching)
                  // in that case get the priority by wrapper
                  if (isset($this->wrappedListeners[$eventName])) {
          Severity: Minor
          Found in src/TraceableEventDispatcher.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

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

              private function trackEventListener($listener): void
              {
                  if (\is_array($listener)) {
                      $this->name   = \is_object($listener[0]) ? get_debug_type($listener[0]) : $listener[0];
                      $this->pretty = $this->name . '::' . $listener[1];
          Severity: Minor
          Found in src/WrappedListener.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

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

              private function sortNotCalledListeners(array $a, array $b): int
              {
                  if (0 !== $cmp = \strcmp($a['event'], $b['event'])) {
                      return $cmp;
                  }
          Severity: Minor
          Found in src/TraceableEventDispatcher.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

          Severity
          Category
          Status
          Source
          Language