Total Complexity | 10 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
8 | class CreateUpdateAwareListener |
||
9 | { |
||
10 | /** |
||
11 | * @var User |
||
12 | */ |
||
13 | private $user; |
||
14 | |||
15 | /** |
||
16 | * CreateUpdateAwareListener constructor. |
||
17 | * @param TokenStorageInterface $tokenStorage |
||
18 | */ |
||
19 | public function __construct(TokenStorageInterface $tokenStorage) |
||
20 | { |
||
21 | if ($tokenStorage->getToken() && is_object($tokenStorage->getToken()->getUser()) && $tokenStorage->getToken()->getUser()->getUser()) { |
||
22 | $this->user = $tokenStorage->getToken()->getUser()->getUser(); |
||
23 | } else { |
||
24 | $this->user = null; |
||
25 | } |
||
26 | } |
||
27 | |||
28 | public function prePersist($entity) |
||
29 | { |
||
30 | if ($this->user) { |
||
31 | if ($entity->getCreatedBy() === null) { |
||
32 | $entity->setCreatedAt(new \DateTime()); |
||
33 | $entity->setCreatedBy($this->user); |
||
34 | } |
||
35 | if ($entity->getUpdatedBy() === null) { |
||
36 | $entity->setUpdatedAt(new \DateTime()); |
||
37 | $entity->setUpdatedBy($this->user); |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 | |||
42 | public function preUpdate($entity) |
||
47 | } |
||
48 | } |
||
49 | } |
||
50 |
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.