EscolaLMS/Webinar

View on GitHub
src/Models/Webinar.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Avoid using static access to class '\Illuminate\Support\Facades\Storage' in method 'getLogotypeUrlAttribute'.
Open

                $logotype = Storage::url(trim($this->attributes['logotype_path'], '/'));
Severity: Minor
Found in src/Models/Webinar.php by phpmd

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 '\Illuminate\Support\Facades\Storage' in method 'getImageUrlAttribute'.
Open

                $imagePath = Storage::url($path);
Severity: Minor
Found in src/Models/Webinar.php by phpmd

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\Webinar\Database\Factories\WebinarFactory' in method 'newFactory'.
Open

        return WebinarFactory::new();
Severity: Minor
Found in src/Models/Webinar.php by phpmd

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

Define a constant instead of duplicating this literal "logotype_path" 3 times.
Open

        if ($this->attributes['logotype_path'] ?? null) {
Severity: Critical
Found in src/Models/Webinar.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "image_path" 3 times.
Open

        'image_path',
Severity: Critical
Found in src/Models/Webinar.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Avoid unused local variables such as '$oa'.
Open

                return preg_match('/^(http|https):.*$/', $imagePath, $oa) ?
Severity: Minor
Found in src/Models/Webinar.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Avoid unused local variables such as '$oa'.
Open

                return preg_match('/^(http|https):.*$/', $logotype, $oa) ?
Severity: Minor
Found in src/Models/Webinar.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Class uses undeclared trait \Illuminate\Database\Eloquent\Factories\HasFactory
Open

class Webinar extends Model
Severity: Critical
Found in src/Models/Webinar.php by phan

Class extends undeclared class \Illuminate\Database\Eloquent\Model
Open

class Webinar extends Model
Severity: Critical
Found in src/Models/Webinar.php by phan

Return type of trainers() is undeclared type \Illuminate\Database\Eloquent\Relations\BelongsToMany
Open

    public function trainers(): BelongsToMany
Severity: Minor
Found in src/Models/Webinar.php by phan

Call to undeclared function \app()
Open

        $webinarServiceContract = app(WebinarServiceContract::class);
Severity: Critical
Found in src/Models/Webinar.php by phan

Reference to undeclared property \EscolaLms\Webinar\Models\Webinar->attributes
Open

            $path = trim(trim($this->attributes['image_path'], '/'));
Severity: Minor
Found in src/Models/Webinar.php by phan

Call to undeclared function \url()
Open

                    url($imagePath);
Severity: Critical
Found in src/Models/Webinar.php by phan

Property \EscolaLms\Webinar\Models\Webinar->active_to has undeclared type ?\Illuminate\Support\Carbon
Open

 * @property ?Carbon $active_to
Severity: Minor
Found in src/Models/Webinar.php by phan

Call to method url from undeclared class \Illuminate\Support\Facades\Storage
Open

                $imagePath = Storage::url($path);
Severity: Critical
Found in src/Models/Webinar.php by phan

Reference to undeclared property \EscolaLms\Webinar\Models\Webinar->attributes
Open

        if ($this->attributes['image_path'] ?? null) {
Severity: Minor
Found in src/Models/Webinar.php by phan

Reference to constant class from undeclared class \EscolaLms\Tags\Models\Tag
Open

        return $this->morphMany(Tag::class, 'morphable');
Severity: Critical
Found in src/Models/Webinar.php by phan

Reference to undeclared property \EscolaLms\Webinar\Models\Webinar->attributes
Open

        if ($this->attributes['logotype_path'] ?? null) {
Severity: Minor
Found in src/Models/Webinar.php by phan

Reference to undeclared property \EscolaLms\Webinar\Models\Webinar->attributes
Open

            $path = trim(trim($this->attributes['logotype_path'], '/'));
Severity: Minor
Found in src/Models/Webinar.php by phan

Call to method url from undeclared class \Illuminate\Support\Facades\Storage
Open

                $logotype = Storage::url(trim($this->attributes['logotype_path'], '/'));
Severity: Critical
Found in src/Models/Webinar.php by phan

Call to undeclared method \EscolaLms\Webinar\Models\Webinar::morphMany
Open

        return $this->morphMany(Tag::class, 'morphable');
Severity: Critical
Found in src/Models/Webinar.php by phan

Call to undeclared function \url()
Open

                    url($logotype);
Severity: Critical
Found in src/Models/Webinar.php by phan

Reference to undeclared property \EscolaLms\Webinar\Models\Webinar->attributes
Open

                $logotype = Storage::url(trim($this->attributes['logotype_path'], '/'));
Severity: Minor
Found in src/Models/Webinar.php by phan

Call to undeclared method \EscolaLms\Webinar\Models\Webinar::belongsToMany
Open

        return $this->belongsToMany(User::class, 'webinar_trainers','webinar_id', 'trainer_id') ;
Severity: Critical
Found in src/Models/Webinar.php by phan

Return type of tags() is undeclared type \Illuminate\Database\Eloquent\Relations\MorphMany
Open

    public function tags(): MorphMany
Severity: Minor
Found in src/Models/Webinar.php by phan

Reference to undeclared property \EscolaLms\Webinar\Models\Webinar->duration
Open

        return $this->duration ?? '';
Severity: Minor
Found in src/Models/Webinar.php by phan

Call to undeclared function \app()
Open

        $webinarServiceContract = app(WebinarServiceContract::class);
Severity: Critical
Found in src/Models/Webinar.php by phan

Call to undeclared method \EscolaLms\Webinar\Models\Webinar::belongsToMany
Open

        return $this->belongsToMany(User::class, 'webinar_user');
Severity: Critical
Found in src/Models/Webinar.php by phan

Return type of users() is undeclared type \Illuminate\Database\Eloquent\Relations\BelongsToMany
Open

    public function users(): BelongsToMany
Severity: Minor
Found in src/Models/Webinar.php by phan

Static call to undeclared method \EscolaLms\Webinar\Database\Factories\WebinarFactory::new
Open

        return WebinarFactory::new();
Severity: Critical
Found in src/Models/Webinar.php by phan

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

        $webinarServiceContract = app(WebinarServiceContract::class);
Severity: Minor
Found in src/Models/Webinar.php by phpmd

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

        $webinarServiceContract = app(WebinarServiceContract::class);
Severity: Minor
Found in src/Models/Webinar.php by phpmd

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

                return preg_match('/^(http|https):.*$/', $imagePath, $oa) ?
Severity: Minor
Found in src/Models/Webinar.php by phpmd

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

                return preg_match('/^(http|https):.*$/', $logotype, $oa) ?
Severity: Minor
Found in src/Models/Webinar.php by phpmd

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

No space found after comma in function call
Open

        return $this->belongsToMany(User::class, 'webinar_trainers','webinar_id', 'trainer_id') ;
Severity: Minor
Found in src/Models/Webinar.php by phpcodesniffer

There are no issues that match your filters.

Category
Status