VSVverkeerskunde/gvq-api

View on GitHub
src/Company/CompaniesCsvData.php

Summary

Maintainability
A
2 hrs
Test Coverage

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

    public function __construct(
        iterable $companies,
        CompanyPlayedQuizzesRepository $companyPlayedQuizzesRepository,
        EmployeeParticipationRepository $employeeParticipationRepository,
        TopScoreRepository $topScoreRepository,
Severity: Minor
Found in src/Company/CompaniesCsvData.php - About 1 hr to fix

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

        private function getValues(Company $company)
        {
            $data = $this->normalizer->normalize($company);
    
            $values = [];
    Severity: Minor
    Found in src/Company/CompaniesCsvData.php - About 1 hr to fix

      Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              iterable $companies,
              CompanyPlayedQuizzesRepository $companyPlayedQuizzesRepository,
              EmployeeParticipationRepository $employeeParticipationRepository,
              TopScoreRepository $topScoreRepository,
              NormalizerInterface $normalizer
      Severity: Minor
      Found in src/Company/CompaniesCsvData.php - About 35 mins to fix

        The method flatten uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        $result[$parentKey . $key] = $value;
                    }
        Severity: Minor
        Found in src/Company/CompaniesCsvData.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

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

        Rename "$headers" which has the same name as the field declared at line 33.
        Open

                $headers = array_fill_keys($this->headers, '');
        Severity: Major
        Found in src/Company/CompaniesCsvData.php by sonar-php

        Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

        Noncompliant Code Example

        class Foo {
          public $myField;
        
          public function doSomething() {
            $myField = 0;
            ...
          }
        }
        

        See

        Avoid excessively long variable names like $companyPlayedQuizzesRepository. Keep variable name length under 20.
        Open

            private $companyPlayedQuizzesRepository;
        Severity: Minor
        Found in src/Company/CompaniesCsvData.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        Avoid excessively long variable names like $employeeParticipationRepository. Keep variable name length under 20.
        Open

                EmployeeParticipationRepository $employeeParticipationRepository,
        Severity: Minor
        Found in src/Company/CompaniesCsvData.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        Avoid excessively long variable names like $companyPlayedQuizzesRepository. Keep variable name length under 20.
        Open

                CompanyPlayedQuizzesRepository $companyPlayedQuizzesRepository,
        Severity: Minor
        Found in src/Company/CompaniesCsvData.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        Avoid variables with short names like $nl. Configured minimum length is 3.
        Open

                $nl = new Language('nl');
        Severity: Minor
        Found in src/Company/CompaniesCsvData.php by phpmd

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#shortvariable

        Avoid variables with short names like $fr. Configured minimum length is 3.
        Open

                $fr = new Language('fr');
        Severity: Minor
        Found in src/Company/CompaniesCsvData.php by phpmd

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#shortvariable

        TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL"
        Open

                    NULL

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

                        $this->flatten($value, $result, $keySeparator,

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

                        $this->flatten($value, $result, $keySeparator,

        Opening parenthesis of a multi-line function call must be the last content on the line
        Open

                        $this->flatten($value, $result, $keySeparator,

        Closing parenthesis of a multi-line function call must be on a line by itself
        Open

                    $fr);

        Closing parenthesis of a multi-line function call must be on a line by itself
        Open

                    $nl);

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

                            $parentKey . $key . $keySeparator);

        Opening parenthesis of a multi-line function call must be the last content on the line
        Open

                $values['played_quizzes.fr'] = $this->companyPlayedQuizzesRepository->getCount($company->getId(),

        Opening parenthesis of a multi-line function call must be the last content on the line
        Open

                $values['played_quizzes.nl'] = $this->companyPlayedQuizzesRepository->getCount($company->getId(),

        Closing parenthesis of a multi-line function call must be on a line by itself
        Open

                            $parentKey . $key . $keySeparator);

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

                    $nl);

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

                    $fr);

        There are no issues that match your filters.

        Category
        Status