EscolaLMS/Consultations

View on GitHub
src/Repositories/ConsultationUserTermRepository.php

Summary

Maintainability
A
1 hr
Test Coverage
C
76%

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

    public function getByCurrentUserTutor(): Collection
    {
        $result = collect();
        $terms = $this->model->newQuery()
            ->whereHas('consultationUser', fn (Builder $query) => $query
Severity: Minor
Found in src/Repositories/ConsultationUserTermRepository.php - About 1 hr to fix

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

                } else {
                    $result->push(new ConsultationUserTermResourceDto(
                        $term->consultation_user_id,
                        $term->consultationUser->consultation_id,
                        $term->executed_at,

    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

    syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'
    Open

            $query->whereHas('consultationUser', fn($query) => $query->where('consultation_id', '=', $consultationId));

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

        public function allQueryBuilder(?FilterConsultationTermsListDto $filterConsultationTermsListDto = null): Collection

    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 $consultationUserPivot. Keep variable name length under 20.
    Open

        public function createUserTerm(ConsultationUserPivot $consultationUserPivot, array $data): ConsultationUserTerm

    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 $consultationUserPivot. Keep variable name length under 20.
    Open

        public function updateUserTermByExecutedAt(ConsultationUserPivot $consultationUserPivot, string $executedAt, array $data): ConsultationUserTerm

    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

    Line exceeds 120 characters; contains 125 characters
    Open

                        ->orWhereHas('teachers', fn (Builder $query) => $query->where('users.id', '=', auth()->user()->getKey()))

    Line exceeds 120 characters; contains 196 characters
    Open

                $userTerm = $result->first(fn (ConsultationUserTermResourceDto $dto) => $dto->consultation_id === $term->consultationUser->consultation_id && $term->executed_at === $dto->executed_at);

    Line exceeds 120 characters; contains 139 characters
    Open

        public function updateByConsultationUserIdAndExecutedAt(int $consultationUserId, string $executedAt, array $data): ConsultationUserTerm

    Line exceeds 120 characters; contains 163 characters
    Open

                    $userTerm->executed_status = $term->executed_status === ConsultationTermStatusEnum::APPROVED ? $term->executed_status : $userTerm->executed_status;

    Line exceeds 120 characters; contains 121 characters
    Open

            $query->whereIn('executed_status', [ConsultationTermStatusEnum::APPROVED, ConsultationTermStatusEnum::REPORTED]);

    Line exceeds 120 characters; contains 147 characters
    Open

        public function updateUserTermByExecutedAt(ConsultationUserPivot $consultationUserPivot, string $executedAt, array $data): ConsultationUserTerm

    Space before opening parenthesis of function call prohibited
    Open

                    ->whereHas('consultation', fn (Builder $query) => $query

    Space before opening parenthesis of function call prohibited
    Open

                $userTerm = $result->first(fn (ConsultationUserTermResourceDto $dto) => $dto->consultation_id === $term->consultationUser->consultation_id && $term->executed_at === $dto->executed_at);

    Expected 0 spaces before closing bracket; newline found
    Open

                ->whereHas('consultationUser', fn (Builder $query) => $query

    Space before opening parenthesis of function call prohibited
    Open

                        ->orWhereHas('teachers', fn (Builder $query) => $query->where('users.id', '=', auth()->user()->getKey()))

    Space before opening parenthesis of function call prohibited
    Open

                ->whereHas('consultationUser', fn (Builder $query) => $query->where('user_id', '=', $userId))

    Expected 0 spaces before closing bracket; newline found
    Open

                    ->whereHas('consultation', fn (Builder $query) => $query

    Space before opening parenthesis of function call prohibited
    Open

                ->whereHas('consultationUser', fn (Builder $query) => $query

    There are no issues that match your filters.

    Category
    Status