susina/config-builder

View on GitHub

Showing 7 of 7 total issues

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

    private function simpleXmlToArray(SimpleXMLElement $xml): array
    {
        $ar = [];
        /**
         * @var int|string $k
Severity: Minor
Found in src/XmlToArrayConverter.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

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

    private function resolveString(string $value, array $resolving = []): mixed
    {
        /*
         * %%: to be unescaped
         * %[^%\s]++%: a parameter
Severity: Minor
Found in src/Loader/FileLoader.php - About 1 hr to fix

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

        private function simpleXmlToArray(SimpleXMLElement $xml): array
        {
            $ar = [];
            /**
             * @var int|string $k
    Severity: Minor
    Found in src/XmlToArrayConverter.php - About 1 hr to fix

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

          private function parse(array $data): array
          {
              $config = [];
      
              foreach ($data as $section => $value) {
      Severity: Minor
      Found in src/Loader/IniFileLoader.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 parseNested has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private function parseNested(string $key, mixed $value, array &$config): void
          {
              if (str_starts_with($key, '.') || str_ends_with($key, '.')) {
                  throw new ConfigurationBuilderException("Invalid key \"$key\"");
              }
      Severity: Minor
      Found in src/Loader/IniFileLoader.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

      Avoid too many return statements within this method.
      Open

              return $this->resolveValue($this->get($onlyKey), $resolving);
      Severity: Major
      Found in src/Loader/FileLoader.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return $replaced;
        Severity: Major
        Found in src/Loader/FileLoader.php - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language