EscolaLMS/Consultations

View on GitHub
src/Services/Contracts/ConsultationServiceContract.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Class "ConsultationServiceContract" has 31 methods, which is greater than 20 authorized. Split it into smaller classes.
Open

interface ConsultationServiceContract

A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

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

    public function getConsultationsList(array $search = [], bool $onlyActive = false, OrderDto $orderDto = null): Builder;

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

Return type of forCurrentUserResponse() is undeclared type \Illuminate\Http\Resources\Json\AnonymousResourceCollection
Open

    public function forCurrentUserResponse(ListConsultationsRequest $listConsultationsRequest): AnonymousResourceCollection;

Return type of getConsultationsListForCurrentUser() is undeclared type \Illuminate\Database\Eloquent\Builder
Open

    public function getConsultationsListForCurrentUser(array $search = []): Builder;

Return type of getConsultationsList() is undeclared type \Illuminate\Database\Eloquent\Builder
Open

    public function getConsultationsList(array $search = [], bool $onlyActive = false, OrderDto $orderDto = null): Builder;

Parameter $orderDto has undeclared type ?\EscolaLms\Core\Dtos\OrderDto
Open

    public function getConsultationsList(array $search = [], bool $onlyActive = false, OrderDto $orderDto = null): Builder;

Return type of getConsultationTermsByConsultationId() is undeclared type \Illuminate\Support\Collection
Open

    public function getConsultationTermsByConsultationId(int $consultationId, array $search = []): Collection;

Parameter $consultationDto has undeclared type \EscolaLms\Consultations\Dto\ConsultationDto
Open

    public function update(int $id, ConsultationDto $consultationDto): Consultation;

Parameter $consultationDto has undeclared type \EscolaLms\Consultations\Dto\ConsultationDto
Open

    public function store(ConsultationDto $consultationDto): Consultation;

Return type of generateDateTo() is undeclared type ?\Carbon\Carbon
Open

    public function generateDateTo(string $dateTo, string $duration): ?Carbon;

Parameter $request has undeclared type \Illuminate\Foundation\Http\FormRequest
Open

    public function updateModelFieldsFromRequest(Consultation $consultation, FormRequest $request): void;

Return type of getConsultationTermsForTutor() is undeclared type \Illuminate\Support\Collection
Open

    public function getConsultationTermsForTutor(): Collection;

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

    public function forCurrentUserResponse(ListConsultationsRequest $listConsultationsRequest): AnonymousResourceCollection;

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

    public function delete(int $id): ?bool;

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

    public function update(int $id, ConsultationDto $consultationDto): Consultation;

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

    public function show(int $id): Consultation;

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

Line exceeds 120 characters; contains 123 characters
Open

    public function getConsultationsList(array $search = [], bool $onlyActive = false, OrderDto $orderDto = null): Builder;

Line exceeds 120 characters; contains 124 characters
Open

    public function forCurrentUserResponse(ListConsultationsRequest $listConsultationsRequest): AnonymousResourceCollection;

There are no issues that match your filters.

Category
Status