laravel/framework

View on GitHub
src/Illuminate/Events/Dispatcher.php

Summary

Maintainability
D
1 day
Test Coverage

File Dispatcher.php has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Illuminate\Events;

use Closure;
Severity: Minor
Found in src/Illuminate/Events/Dispatcher.php - About 5 hrs to fix

    Dispatcher has 39 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Dispatcher implements DispatcherContract
    {
        use Macroable, ReflectsClosures;
    
        /**
    Severity: Minor
    Found in src/Illuminate/Events/Dispatcher.php - About 5 hrs to fix

      Function subscribe has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function subscribe($subscriber)
          {
              $subscriber = $this->resolveSubscriber($subscriber);
      
              $events = $subscriber->subscribe($this);
      Severity: Minor
      Found in src/Illuminate/Events/Dispatcher.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 invokeListeners has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function invokeListeners($event, $payload, $halt = false)
          {
              if ($this->shouldBroadcast($payload)) {
                  $this->broadcastEvent($payload[0]);
              }
      Severity: Minor
      Found in src/Illuminate/Events/Dispatcher.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 listen has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function listen($events, $listener = null)
          {
              if ($events instanceof Closure) {
                  return collect($this->firstClosureParameterTypes($events))
                      ->each(function ($event) use ($events) {
      Severity: Minor
      Found in src/Illuminate/Events/Dispatcher.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 getWildcardListeners has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getWildcardListeners($eventName)
          {
              $wildcards = [];
      
              foreach ($this->wildcards as $key => $listeners) {
      Severity: Minor
      Found in src/Illuminate/Events/Dispatcher.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 addInterfaceListeners has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function addInterfaceListeners($eventName, array $listeners = [])
          {
              foreach (class_implements($eventName) as $interface) {
                  if (isset($this->listeners[$interface])) {
                      foreach ($this->prepareListeners($interface) as $names) {
      Severity: Minor
      Found in src/Illuminate/Events/Dispatcher.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

      There are no issues that match your filters.

      Category
      Status