VSVverkeerskunde/gvq-api

View on GitHub
src/Contest/Models/ContestParticipation.php

Summary

Maintainability
A
1 hr
Test Coverage

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

        UuidInterface $id,
        Year $year,
        Language $language,
        QuizChannel $channel,
        ContestParticipant $contestParticipant,
Severity: Major
Found in src/Contest/Models/ContestParticipation.php - About 1 hr to fix

    The method __construct has 11 parameters. Consider reducing the number of parameters to less than 10.
    Open

        public function __construct(
            UuidInterface $id,
            Year $year,
            Language $language,
            QuizChannel $channel,

    This function has 11 parameters, which is greater than the 7 authorized.
    Open

        public function __construct(
            UuidInterface $id,
            Year $year,
            Language $language,
            QuizChannel $channel,

    A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

    Noncompliant Code Example

    With a maximum number of 4 parameters:

    function doSomething($param1, $param2, $param3, $param4, $param5) {
    ...
    }
    

    Compliant Solution

    function doSomething($param1, $param2, $param3, $param4) {
    ...
    }
    

    Missing class import via use statement (line '225', column '23').
    Open

                throw new \InvalidArgumentException('GDPR1 should be accepted.');

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

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

            ?bool $associationMember = false

    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

    Missing class import via use statement (line '212', column '23').
    Open

                throw new \InvalidArgumentException(

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

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

            UuidInterface $id,

    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 $id. Configured minimum length is 3.
    Open

        private $id;

    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

    There are no issues that match your filters.

    Category
    Status