Total Complexity | 4 |
Total Lines | 27 |
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 RoleInterface $role |
||
20 | * @param ResourceInterface $resource |
||
21 | * @param string $privilege |
||
22 | * |
||
23 | * @return bool |
||
24 | */ |
||
25 | public function assert(Acl $acl, ?RoleInterface $role = null, ?ResourceInterface $resource = null, $privilege = null) |
||
26 | { |
||
27 | /** @var HasOwner $object */ |
||
28 | $object = $resource->getInstance(); |
||
29 | |||
30 | if (CurrentUser::get() && CurrentUser::get() === $object->getOwner()) { |
||
31 | return true; |
||
32 | } |
||
33 | |||
34 | return $acl->reject('the object does not belong to the user'); |
||
35 | } |
||
36 | |||
37 | public function getName(): string |
||
40 | } |
||
41 | } |
||
42 |
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.