Total Complexity | 9 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
19 | class Logger implements LoggerInterface |
||
20 | { |
||
21 | private $entityDeleteLogs = []; |
||
22 | |||
23 | public function __construct(private ManagerRegistry $doctrine) |
||
24 | { |
||
25 | } |
||
26 | |||
27 | #[\Override] |
||
28 | public function log(AuditLog $event = null) |
||
29 | { |
||
30 | if (empty($event)) { |
||
31 | return; |
||
32 | } |
||
33 | |||
34 | if (DoctrineEvents::ENTITY_DELETED === $event->getTypeId()) { |
||
35 | $this->entityDeleteLogs[] = $event; |
||
36 | |||
37 | return; |
||
38 | } |
||
39 | |||
40 | $this->saveLog($event); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @return ObjectManager |
||
45 | */ |
||
46 | protected function getManager() |
||
47 | { |
||
48 | return $this->getDoctrine()->getManager(); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return ManagerRegistry |
||
53 | */ |
||
54 | public function getDoctrine() |
||
55 | { |
||
56 | return $this->doctrine; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @param AuditLog $event |
||
61 | */ |
||
62 | protected function saveLog(AuditLog $event) |
||
66 | } |
||
67 | |||
68 | public function savePendingLogs() |
||
69 | { |
||
75 | } |
||
76 | } |
||
77 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.