src/Policies/WebinarPolicy.php
Call to method where
from undeclared class \Illuminate\Database\Eloquent\Relations\BelongsToMany
Open
Open
&& $webinar->trainers()->where('trainer_id', $user->getKey())->exists()
- Exclude checks
Call to method getKey
from undeclared class \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
&& $webinar->trainers()->where('trainer_id', $user->getKey())->exists()
- Exclude checks
Call to method can
from undeclared class \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
return $user->can(WebinarPermissionsEnum::WEBINAR_UPDATE)
- Exclude checks
Call to method can
from undeclared class \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
return $user->can(WebinarPermissionsEnum::WEBINAR_READ)
- Exclude checks
Parameter $user
has undeclared type \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
public function delete(User $user, Webinar $webinar): bool
- Exclude checks
Class uses undeclared trait \Illuminate\Auth\Access\HandlesAuthorization
Open
Open
class WebinarPolicy
- Exclude checks
Call to method getKey
from undeclared class \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
&& $webinar->trainers()->where('trainer_id', $user->getKey())->exists()
- Exclude checks
Call to method getKey
from undeclared class \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
&& $webinar->trainers()->where('trainer_id', $user->getKey())->exists()
- Exclude checks
Call to method can
from undeclared class \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
return $user->can(WebinarPermissionsEnum::WEBINAR_CREATE);
- Exclude checks
Parameter $user
has undeclared type \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
public function update(User $user, Webinar $webinar): bool
- Exclude checks
Parameter $user
has undeclared type \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
public function create(User $user): bool
- Exclude checks
Call to method can
from undeclared class \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
$user->can(WebinarPermissionsEnum::WEBINAR_UPDATE_OWN)
- Exclude checks
Parameter $user
has undeclared type \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
public function list(User $user): bool
- Exclude checks
Call to method where
from undeclared class \Illuminate\Database\Eloquent\Relations\BelongsToMany
Open
Open
&& $webinar->trainers()->where('trainer_id', $user->getKey())->exists()
- Exclude checks
Call to method can
from undeclared class \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
return $user->can(WebinarPermissionsEnum::WEBINAR_DELETE)
- Exclude checks
Call to method canAny
from undeclared class \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
return $user->canAny([WebinarPermissionsEnum::WEBINAR_LIST, WebinarPermissionsEnum::WEBINAR_LIST_OWN]);
- Exclude checks
Parameter $user
has undeclared type \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
public function read(User $user, Webinar $webinar): bool
- Exclude checks
Call to method can
from undeclared class \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
$user->can(WebinarPermissionsEnum::WEBINAR_DELETE_OWN)
- Exclude checks
Call to method where
from undeclared class \Illuminate\Database\Eloquent\Relations\BelongsToMany
Open
Open
&& $webinar->trainers()->where('trainer_id', $user->getKey())->exists()
- Exclude checks
Call to method can
from undeclared class \EscolaLms\Auth\Models\User
(Did you mean class \EscolaLms\Webinar\Models\User) Open
Open
$user->can(WebinarPermissionsEnum::WEBINAR_READ_OWN)
- Exclude checks
Define a constant instead of duplicating this literal "trainer_id" 3 times. Open
Open
&& $webinar->trainers()->where('trainer_id', $user->getKey())->exists()
- Read upRead up
- Exclude checks
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.