Completed
Push — master ( 2cfa94...8372b9 )
by
32:31
created

UserSecurityRoleListener   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
c 1
b 1
f 0
lcom 0
cbo 3
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A resizeUserRoles() 0 16 3
1
<?php
2
3
namespace DoS\UserBundle\EventListener;
4
5
use DoS\UserBundle\Model\CustomerInterface;
6
use Sylius\Component\Rbac\Model\IdentityInterface;
7
use Sylius\Component\Resource\Event\ResourceEvent;
8
9
class UserSecurityRoleListener
10
{
11
    public function resizeUserRoles(ResourceEvent $event)
12
    {
13
        $object = $event->getSubject();
14
15
        if (!$object instanceof CustomerInterface) {
16
            return;
17
        }
18
19
        $user = $object->getUser();
20
21
        if (!$user instanceof IdentityInterface) {
22
            return;
23
        }
24
25
        $user->resizeSecurityRoles();
26
    }
27
}
28