wol-soft/php-json-schema-model-generator

View on GitHub
src/Model/Property/Property.php

Summary

Maintainability
A
3 hrs
Test Coverage
A
100%

Property has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class Property extends AbstractProperty
{
    /** @var PropertyType|null */
    protected $outputType;
    /** @var bool */
Severity: Minor
Found in src/Model/Property/Property.php - About 2 hrs to fix

    Method getTypeHint has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getTypeHint(bool $outputType = false, array $skipDecorators = []): string
        {
            if (isset($this->renderedTypeHints[$outputType])) {
                return $this->renderedTypeHints[$outputType];
            }
    Severity: Minor
    Found in src/Model/Property/Property.php - About 1 hr to fix

      The method getTypeHint() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
      Open

          public function getTypeHint(bool $outputType = false, array $skipDecorators = []): string
          {
              if (isset($this->renderedTypeHints[$outputType])) {
                  return $this->renderedTypeHints[$outputType];
              }
      Severity: Minor
      Found in src/Model/Property/Property.php by phpmd

      CyclomaticComplexity

      Since: 0.1

      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

      Example

      // Cyclomatic Complexity = 11
      class Foo {
      1   public function example() {
      2       if ($a == $b) {
      3           if ($a1 == $b1) {
                      fiddle();
      4           } elseif ($a2 == $b2) {
                      fiddle();
                  } else {
                      fiddle();
                  }
      5       } elseif ($c == $d) {
      6           while ($c == $d) {
                      fiddle();
                  }
      7        } elseif ($e == $f) {
      8           for ($n = 0; $n < $h; $n++) {
                      fiddle();
                  }
              } else {
                  switch ($z) {
      9               case 1:
                          fiddle();
                          break;
      10              case 2:
                          fiddle();
                          break;
      11              case 3:
                          fiddle();
                          break;
                      default:
                          fiddle();
                          break;
                  }
              }
          }
      }

      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

      The method getType has a boolean flag argument $outputType, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function getType(bool $outputType = false): ?PropertyType
      Severity: Minor
      Found in src/Model/Property/Property.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

      Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

      The method setDefaultValue has a boolean flag argument $raw, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function setDefaultValue($defaultValue, bool $raw = false): PropertyInterface
      Severity: Minor
      Found in src/Model/Property/Property.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

      Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

      The method setType has a boolean flag argument $reset, which is a certain sign of a Single Responsibility Principle violation.
      Open

              bool $reset = false,
      Severity: Minor
      Found in src/Model/Property/Property.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

      Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

      The method getTypeHint has a boolean flag argument $outputType, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function getTypeHint(bool $outputType = false, array $skipDecorators = []): string
      Severity: Minor
      Found in src/Model/Property/Property.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

      Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

      syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST)
      Open

          private array $renderedTypeHints = [];
      Severity: Critical
      Found in src/Model/Property/Property.php by phan

      Only one argument is allowed per line in a multi-line function call
      Open

                          static fn(TypeHintDecoratorInterface $decorator): bool => !in_array($decorator::class, $skipDec),

      Arguments with default values must be at the end of the argument list
      Open

              protected string $description = '',

      Arguments with default values must be at the end of the argument list
      Open

              bool $reset = false,

      Multi-line function call not indented correctly; expected 12 spaces but found 16
      Open

                      $validator->getPriority() <=> $comparedValidator->getPriority(),

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              protected ?PropertyType $type,

      Line indented incorrectly; expected 16 spaces, found 20
      Open

                          static fn(TypeHintDecoratorInterface $decorator): bool => !in_array($decorator::class, $skipDec),

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  static fn(Validator $validator): PropertyValidatorInterface => $validator->getValidator(),

      Line indented incorrectly; expected 8 spaces, found 12
      Open

                  static fn(Validator $validator, Validator $comparedValidator): int =>

      Line indented incorrectly; expected 4 spaces, found 8
      Open

              protected string $description = '',

      There are no issues that match your filters.

      Category
      Status