biurad/flange

View on GitHub
src/Extensions/EventDispatcherExtension.php

Summary

Maintainability
D
1 day
Test Coverage

Function doEventsRegister has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    private function doEventsRegister(Container $container, Definition $eventDispatcher, string $listenerTag, array $eventSubscribers)
    {
        [$subscriberTag, $eventSubscribers] = $eventSubscribers;

        foreach ($container->tagged($listenerTag) as $id => $event) {
Severity: Minor
Found in src/Extensions/EventDispatcherExtension.php - About 1 day 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 doEventsRegister has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function doEventsRegister(Container $container, Definition $eventDispatcher, string $listenerTag, array $eventSubscribers)
    {
        [$subscriberTag, $eventSubscribers] = $eventSubscribers;

        foreach ($container->tagged($listenerTag) as $id => $event) {
Severity: Major
Found in src/Extensions/EventDispatcherExtension.php - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

            if (
                null === ($class = $container->definition($id)->getEntity())
                || !($r = new \ReflectionClass($class))
                || !$r->hasMethod($method)
                || 1 > ($m = $r->getMethod($method))->getNumberOfParameters()
    Severity: Major
    Found in src/Extensions/EventDispatcherExtension.php - About 1 hr to fix

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

          public function register(Container $container, array $configs = []): void
          {
              if (isset($configs['dispatcher_class'])) {
                  $dispatcher = $configs['dispatcher_class'];
      
      
      Severity: Minor
      Found in src/Extensions/EventDispatcherExtension.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 boot has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function boot(Container $container): void
          {
              if ($container->has('events.dispatcher')) {
                  if ($container->shared('events.dispatcher')) {
                      $container->removeShared('events.dispatcher');
      Severity: Minor
      Found in src/Extensions/EventDispatcherExtension.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