Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
60.00% |
3 / 5 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
| ApieUserDecorator | |
60.00% |
3 / 5 |
|
33.33% |
1 / 3 |
5.02 | |
0.00% |
0 / 1 |
| getRoles | |
66.67% |
2 / 3 |
|
0.00% |
0 / 1 |
2.15 | |||
| eraseCredentials | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUserIdentifier | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Apie\ApieBundle\Security; |
| 4 | |
| 5 | use Apie\Common\Interfaces\HasRolesInterface; |
| 6 | use Apie\Common\Wrappers\AbstractApieUserDecorator; |
| 7 | use Apie\Core\Entities\EntityInterface; |
| 8 | use Symfony\Component\Security\Core\User\UserInterface; |
| 9 | |
| 10 | /** |
| 11 | * Decorator around an Apie entity to tell Symfony we are logged in. |
| 12 | * |
| 13 | * @template T of EntityInterface |
| 14 | * @extends AbstractApieUserDecorator<T> |
| 15 | */ |
| 16 | final class ApieUserDecorator extends AbstractApieUserDecorator implements UserInterface |
| 17 | { |
| 18 | public function getRoles(): array |
| 19 | { |
| 20 | if ($this->entity instanceof HasRolesInterface) { |
| 21 | return $this->entity->getRoles()->toArray(); |
| 22 | } |
| 23 | return []; |
| 24 | } |
| 25 | |
| 26 | public function eraseCredentials(): void |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | public function getUserIdentifier(): string |
| 31 | { |
| 32 | return $this->id->toNative(); |
| 33 | } |
| 34 | } |