EscolaLMS/Consultations

View on GitHub
src/Http/Resources/ConsultationUserTermsResource.php

Summary

Maintainability
A
1 hr
Test Coverage
A
100%

Method toArray has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function toArray($request)
    {
        $consultationServiceContract = app(ConsultationServiceContract::class);

        $consultation = $this->resource->consultationUser->consultation;
Severity: Minor
Found in src/Http/Resources/ConsultationUserTermsResource.php - About 1 hr to fix

    Avoid using static access to class '\Illuminate\Support\Carbon' in method 'toArray'.
    Open

                'date' => Carbon::make($this->resource->executed_at) ?? '',

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class 'EscolaLms\Consultations\Http\Resources\ConsultationAuthorResource' in method 'toArray'.
    Open

                    ConsultationAuthorResource::make($this->resource->consultationUser->user) :

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class 'EscolaLms\Consultations\Http\Resources\ConsultationAuthorResource' in method 'toArray'.
    Open

                'author' =>  $consultation->author ? ConsultationAuthorResource::make($consultation->author) : null,

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class 'EscolaLms\Consultations\Http\Resources\ConsultationTermResource' in method 'toArray'.
    Open

                'busy_terms' => ConsultationTermResource::collection($consultationServiceContract->getBusyTermsFormatDate($consultation->getKey())),

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid unused parameters such as '$request'.
    Open

        public function toArray($request)

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

                'consultation_term_id' => $this->resource->consultation_user_id,

    Static call to undeclared method \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource::apply
    Open

            return self::apply($fields, $this);

    Call to method make from undeclared class \Illuminate\Support\Carbon
    Open

                'date' => Carbon::make($this->resource->executed_at) ?? '',

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

                'status' => $this->resource->executed_status ?? '',

    Call to undeclared function \app()
    Open

            $consultationServiceContract = app(ConsultationServiceContract::class);

    Static call to undeclared method \EscolaLms\Consultations\Http\Resources\ConsultationAuthorResource::make
    Open

                    ConsultationAuthorResource::make($this->resource->consultationUser->user) :

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

                    $this->resource->executed_at,

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

                'finished_at' => $this->resource->finished_at,

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

                'date' => Carbon::make($this->resource->executed_at) ?? '',

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

                    $this->resource->executed_at,

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

                    $this->resource->executed_status,

    Class uses undeclared trait \EscolaLms\Auth\Traits\ResourceExtandable
    Open

    class ConsultationUserTermsResource extends JsonResource

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

                    $this->resource->executed_status,

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

                    ConsultationAuthorResource::make($this->resource->consultationUser->user) :

    Class extends undeclared class \Illuminate\Http\Resources\Json\JsonResource
    Open

    class ConsultationUserTermsResource extends JsonResource

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

            $consultation = $this->resource->consultationUser->consultation;

    Static call to undeclared method \EscolaLms\Consultations\Http\Resources\ConsultationAuthorResource::make
    Open

                'author' =>  $consultation->author ? ConsultationAuthorResource::make($consultation->author) : null,

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

                'user' => isset($this->resource->consultationUser->user) ?

    Reference to undeclared property \EscolaLms\Consultations\Http\Resources\ConsultationUserTermsResource->resource
    Open

                    $this->resource->executed_at,

    Static call to undeclared method \EscolaLms\Consultations\Http\Resources\ConsultationTermResource::collection
    Open

                'busy_terms' => ConsultationTermResource::collection($consultationServiceContract->getBusyTermsFormatDate($consultation->getKey())),

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

            $consultationServiceContract = app(ConsultationServiceContract::class);

    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 144 characters
    Open

                'busy_terms' => ConsultationTermResource::collection($consultationServiceContract->getBusyTermsFormatDate($consultation->getKey())),

    There are no issues that match your filters.

    Category
    Status