Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
SymfonyUserDecoratorFactory | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
create | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace Apie\ApieBundle\Wrappers; |
4 | |
5 | use Apie\ApieBundle\Security\SymfonyUserDecorator; |
6 | use Apie\ApieBundle\Security\SymfonyUserWithPermissionDecorator; |
7 | use Apie\Core\Entities\EntityInterface; |
8 | use Apie\Core\Permissions\PermissionInterface; |
9 | use Symfony\Component\Security\Core\User\UserInterface; |
10 | |
11 | class SymfonyUserDecoratorFactory |
12 | { |
13 | public function create(UserInterface $user): SymfonyUserDecorator|EntityInterface |
14 | { |
15 | if ($user instanceof EntityInterface) { |
16 | return $user; |
17 | } |
18 | if ($user instanceof PermissionInterface) { |
19 | return new SymfonyUserWithPermissionDecorator($user); |
20 | } |
21 | return new SymfonyUserDecorator($user); |
22 | } |
23 | } |