src/Services/Contracts/ConsultationServiceContract.php
Class "ConsultationServiceContract" has 33 methods, which is greater than 20 authorized. Split it into smaller classes. Open
Open
interface ConsultationServiceContract
- Read upRead up
- Exclude checks
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
Open
public function getConsultationsList(array $search = [], bool $onlyActive = false, OrderDto $orderDto = null): Builder;
- Read upRead up
- Exclude checks
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
Parameter $dto
has undeclared type \EscolaLms\Consultations\Dto\ConsultationUserTermDto
Open
Open
public function rejectTerm(int $consultationTermId, ConsultationUserTermDto $dto): bool;
- Exclude checks
Parameter $dto
has undeclared type \EscolaLms\Consultations\Dto\FinishTermDto
Open
Open
public function finishTerm(int $consultationTermId, FinishTermDto $dto): bool;
- Exclude checks
Parameter $consultationDto
has undeclared type \EscolaLms\Consultations\Dto\ConsultationDto
Open
Open
public function update(int $id, ConsultationDto $consultationDto): Consultation;
- Exclude checks
Parameter $orderDto
has undeclared type ?\EscolaLms\Core\Dtos\OrderDto
Open
Open
public function getConsultationsList(array $search = [], bool $onlyActive = false, OrderDto $orderDto = null): Builder;
- Exclude checks
Parameter $consultationDto
has undeclared type \EscolaLms\Consultations\Dto\ConsultationDto
Open
Open
public function store(ConsultationDto $consultationDto): Consultation;
- Exclude checks
Return type of generateDateTo()
is undeclared type ?\Carbon\Carbon
Open
Open
public function generateDateTo(string $dateTo, string $duration): ?Carbon;
- Exclude checks
Return type of getConsultationTermsForTutor()
is undeclared type \Illuminate\Support\Collection
Open
Open
public function getConsultationTermsForTutor(): Collection;
- Exclude checks
Parameter $dto
has undeclared type \EscolaLms\Consultations\Dto\ConsultationSaveScreenDto
Open
Open
public function saveScreen(ConsultationSaveScreenDto $dto): void;
- Exclude checks
Parameter $dto
has undeclared type \EscolaLms\Consultations\Dto\ConsultationUserTermDto
Open
Open
public function approveTerm(int $consultationTermId, ConsultationUserTermDto $dto): bool;
- Exclude checks
Parameter $dto
has undeclared type \EscolaLms\Consultations\Dto\ConsultationUserTermDto
Open
Open
public function generateJitsi(int $consultationTermId, ConsultationUserTermDto $dto): array;
- Exclude checks
Return type of forCurrentUserResponse()
is undeclared type \Illuminate\Http\Resources\Json\AnonymousResourceCollection
Open
Open
public function forCurrentUserResponse(ListConsultationsRequest $listConsultationsRequest): AnonymousResourceCollection;
- Exclude checks
Return type of getConsultationsListForCurrentUser()
is undeclared type \Illuminate\Database\Eloquent\Builder
Open
Open
public function getConsultationsListForCurrentUser(array $search = []): Builder;
- Exclude checks
Parameter $dto
has undeclared type \EscolaLms\Consultations\Dto\ChangeTermConsultationDto
Open
Open
public function changeTerm(int $consultationTermId, ChangeTermConsultationDto $dto): bool;
- Exclude checks
Parameter $request
has undeclared type \Illuminate\Foundation\Http\FormRequest
Open
Open
public function updateModelFieldsFromRequest(Consultation $consultation, FormRequest $request): void;
- Exclude checks
Return type of getConsultationTermsByConsultationId()
is undeclared type \Illuminate\Support\Collection
Open
Open
public function getConsultationTermsByConsultationId(int $consultationId, array $search = []): Collection;
- Exclude checks
Return type of getConsultationsList()
is undeclared type \Illuminate\Database\Eloquent\Builder
Open
Open
public function getConsultationsList(array $search = [], bool $onlyActive = false, OrderDto $orderDto = null): Builder;
- Exclude checks
Avoid excessively long variable names like $listConsultationsRequest. Keep variable name length under 20. Open
Open
public function forCurrentUserResponse(ListConsultationsRequest $listConsultationsRequest): AnonymousResourceCollection;
- Read upRead up
- Exclude checks
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
Open
public function delete(int $id): ?bool;
- Read upRead up
- Exclude checks
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
Open
public function update(int $id, ConsultationDto $consultationDto): Consultation;
- Read upRead up
- Exclude checks
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
Open
public function show(int $id): Consultation;
- Read upRead up
- Exclude checks
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 124 characters Open
Open
public function forCurrentUserResponse(ListConsultationsRequest $listConsultationsRequest): AnonymousResourceCollection;
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
Open
public function setStatus(ConsultationUserPivot $consultationTerm, string $status, string $executedAt): ConsultationUserTerm;
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
Open
public function getConsultationsList(array $search = [], bool $onlyActive = false, OrderDto $orderDto = null): Builder;
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
Open
public function canGenerateJitsi(?string $executedAt, ?string $status, ?string $duration, ?Consultation $consultation): bool;
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
Open
public function setReminderStatus(ConsultationUserPivot $consultationTerm, string $status, ?ConsultationUserTerm $userTerm = null): void;
- Exclude checks