phpexpertsinc/SimpleDTO

View on GitHub

Showing 6 of 6 total issues

Function loadConcreteProperties has a Cognitive Complexity of 31 (exceeds 10 allowed). Consider refactoring.
Open

    private function loadConcreteProperties(array $input): void
    {
        $properties = (new ReflectionClass($this))->getProperties(\ReflectionProperty::IS_PROTECTED);
        foreach ($properties as $property) {
            if ($property->isStatic()) {
Severity: Minor
Found in src/SimpleDTO.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 SimpleDTO.php has 297 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

/**
 * This file is part of SimpleDTO, a PHP Experts, Inc., Project.
 *
Severity: Minor
Found in src/SimpleDTO.php - About 3 hrs to fix

    Method loadConcreteProperties has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function loadConcreteProperties(array $input): void
        {
            $properties = (new ReflectionClass($this))->getProperties(\ReflectionProperty::IS_PROTECTED);
            foreach ($properties as $property) {
                if ($property->isStatic()) {
    Severity: Minor
    Found in src/SimpleDTO.php - About 1 hr to fix

      Method __construct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct(array $input, array $DTOs, array $options = null, DataTypeValidator $validator = null)
          {
              $filterArraySymbol = function (array $DTOs): array {
                  $results = [];
                  foreach ($DTOs as $key => $value) {
      Severity: Minor
      Found in src/NestedDTO.php - About 1 hr to fix

        Function processDTOArray has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
        Open

            private function processDTOArray(array &$input, string $property, $dtoClass, ?array $options): void
            {
                $newProperty = substr($property, -2) === '[]' ? substr($property, 0, -2) : $property;
        
                if (!is_array($input[$property] ?? null) && !is_array($input[$newProperty] ?? null)) {
        Severity: Minor
        Found in src/NestedDTO.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 processCarbonProperties has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
        Open

            private function processCarbonProperties(array &$input): void
            {
                foreach ($this->dataTypeRules as $property => &$expectedType) {
                    // Make every property nullable if in PERMISSIVE mode.
                    $this->handlePermissiveMode($expectedType);
        Severity: Minor
        Found in src/SimpleDTO.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

        Severity
        Category
        Status
        Source
        Language