biurad/php-dependency-injection

View on GitHub

Showing 44 of 44 total issues

Function convertDomElementToArray has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function convertDomElementToArray(DOMElement $element, bool $checkPrefix = true)
    {
        $prefix = (string) $element->prefix;
        $empty  = true;
        $config = [];
Severity: Minor
Found in src/Adapters/XmlAdapter.php - About 3 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 addBranch has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    protected function addBranch($branchName, array $config, XMLWriter $writer): void
    {
        $branchType = null;

        foreach ($config as $key => $value) {
Severity: Minor
Found in src/Adapters/XmlAdapter.php - About 3 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

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

    Function getParameter has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getParameter(string $name)
        {
            if (!\array_key_exists($name, $this->parameters)) {
                $alternatives = [];
    
    
    Severity: Minor
    Found in src/Builder.php - About 3 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

    File XmlAdapter.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    /*
    Severity: Minor
    Found in src/Adapters/XmlAdapter.php - About 2 hrs to fix

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

          private static function autowireArgument(ReflectionParameter $parameter, callable $getter)
          {
              $type = Reflection::getParameterType($parameter);
              $method = $parameter->getDeclaringFunction();
              $desc = Reflection::toString($parameter);
      Severity: Minor
      Found in src/Resolver.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

      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

        Consider simplifying this complex logical expression.
        Open

                if ($type && !Reflection::isBuiltinType($type)) {
                    try {
                        $res = $getter($type, true);
                    } catch (MissingServiceException $e) {
                        $res = null;
        Severity: Critical
        Found in src/Resolver.php - About 2 hrs to fix

          Function parse has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              public function parse(string $content, $schemaOrCallable = null): DOMDocument
              {
                  $internalErrors  = \libxml_use_internal_errors(true);
                  \libxml_clear_errors();
          
          
          Severity: Minor
          Found in src/Adapters/XmlAdapter.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 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

          Method convertDomElementToArray has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function convertDomElementToArray(DOMElement $element, bool $checkPrefix = true)
              {
                  $prefix = (string) $element->prefix;
                  $empty  = true;
                  $config = [];
          Severity: Minor
          Found in src/Adapters/XmlAdapter.php - About 1 hr to fix

            Method addBranch has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function addBranch($branchName, array $config, XMLWriter $writer): void
                {
                    $branchType = null;
            
                    foreach ($config as $key => $value) {
            Severity: Minor
            Found in src/Adapters/XmlAdapter.php - About 1 hr to fix

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

                  public static function arrayGet($array, $key, $default = null)
                  {
                      if (!\is_array($array) && !$array instanceof ArrayAccess) {
                          throw new InvalidArgumentException('First parameter must be an array or ArrayAccess object.');
                      }
              Severity: Minor
              Found in src/Builder.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 parse has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function parse(string $content, $schemaOrCallable = null): DOMDocument
                  {
                      $internalErrors  = \libxml_use_internal_errors(true);
                      \libxml_clear_errors();
              
              
              Severity: Minor
              Found in src/Adapters/XmlAdapter.php - About 1 hr to fix

                Method autowireArgument has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static function autowireArgument(ReflectionParameter $parameter, callable $getter)
                    {
                        $type = Reflection::getParameterType($parameter);
                        $method = $parameter->getDeclaringFunction();
                        $desc = Reflection::toString($parameter);
                Severity: Minor
                Found in src/Resolver.php - About 1 hr to fix

                  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 arrayGet has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function arrayGet($array, $key, $default = null)
                        {
                            if (!\is_array($array) && !$array instanceof ArrayAccess) {
                                throw new InvalidArgumentException('First parameter must be an array or ArrayAccess object.');
                            }
                    Severity: Minor
                    Found in src/Builder.php - About 1 hr to fix

                      Method getParameter has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getParameter(string $name)
                          {
                              if (!\array_key_exists($name, $this->parameters)) {
                                  $alternatives = [];
                      
                      
                      Severity: Minor
                      Found in src/Builder.php - About 1 hr to fix

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

                            public function dump(array $data): string
                            {
                                $writer = new XMLWriter();
                                $writer->openMemory();
                                $writer->setIndent(true);
                        Severity: Minor
                        Found in src/Adapters/XmlAdapter.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language