| Total Complexity | 4 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | final class IsOwner implements NamedAssertion |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * Assert that the object belongs to the current user. |
||
| 17 | * |
||
| 18 | * @param \Ecodev\Felix\Acl\Acl $acl |
||
| 19 | * @param ?string $privilege |
||
| 20 | */ |
||
| 21 | public function assert(Acl $acl, ?RoleInterface $role = null, ?ResourceInterface $resource = null, $privilege = null): bool |
||
| 22 | { |
||
| 23 | /** @var HasOwner $object */ |
||
| 24 | $object = $resource->getInstance(); |
||
|
|
|||
| 25 | |||
| 26 | if (CurrentUser::get() && CurrentUser::get() === $object->getOwner()) { |
||
| 27 | return true; |
||
| 28 | } |
||
| 29 | |||
| 30 | return $acl->reject('the object does not belong to the user'); |
||
| 31 | } |
||
| 32 | |||
| 33 | public function getName(): string |
||
| 36 | } |
||
| 37 | } |
||
| 38 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.