biurad/php-dependency-injection

View on GitHub
src/Container.php

Summary

Maintainability
D
1 day
Test Coverage

File Container.php has 304 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

/*
Severity: Minor
Found in src/Container.php - About 3 hrs to fix

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

    class Container extends NetteContainer implements FactoryInterface
    {
        /** @var object[] service name => instance */
        private $instances = [];
    
    
    Severity: Minor
    Found in src/Container.php - About 2 hrs to fix

      Function createInstance has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function createInstance(string $class, array $args = [])
          {
              try {
                  $reflector = new \ReflectionClass($class);
              } catch (\ReflectionException $e) {
      Severity: Minor
      Found in src/Container.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 getByType has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getByType(string $type, bool $throw = true)
          {
              $type = Helpers::normalizeClass($type);
      
              if (!empty($this->wiring[$type][0])) {
      Severity: Minor
      Found in src/Container.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 getByType has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getByType(string $type, bool $throw = true)
          {
              $type = Helpers::normalizeClass($type);
      
              if (!empty($this->wiring[$type][0])) {
      Severity: Minor
      Found in src/Container.php - About 1 hr to fix

        Method createInstance has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function createInstance(string $class, array $args = [])
            {
                try {
                    $reflector = new \ReflectionClass($class);
                } catch (\ReflectionException $e) {
        Severity: Minor
        Found in src/Container.php - About 1 hr to fix

          Method createService has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function createService(string $name, array $args = [])
              {
                  $name   = $this->aliases[$name] ?? $name;
                  $method = self::getMethodName($name);
                  $cb     = $this->methods[$method] ?? null;
          Severity: Minor
          Found in src/Container.php - About 1 hr to fix

            Function make has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function make(string $alias, ...$parameters)
                {
                    try {
                        return $this->getService($alias);
                    } catch (MissingServiceException $e) {
            Severity: Minor
            Found in src/Container.php - About 55 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 addService has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function addService(string $name, $service)
                {
                    $service = null === $service ? $name : $service;
                    $name    = $this->aliases[$name] ?? $name;
            
            
            Severity: Minor
            Found in src/Container.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 runScope has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function runScope(array $bindings, callable $scope)
                {
                    $cleanup = $previous = [];
            
                    foreach ($bindings as $alias => $resolver) {
            Severity: Minor
            Found in src/Container.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