| Conditions | 7 |
| Paths | 5 |
| Total Lines | 38 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 8.2747 |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | 2 | public function process(ContainerBuilder $container) |
|
| 24 | { |
||
| 25 | 2 | if (!is_dir(ROOT . 'cache')) { |
|
| 26 | return; |
||
| 27 | } |
||
| 28 | |||
| 29 | 2 | $events = []; |
|
| 30 | 2 | foreach (get_declared_classes() as $class) { |
|
| 31 | 2 | $reflection = new ReflectionClass($class); |
|
| 32 | |||
| 33 | 2 | if (!$reflection->isSubclassOf(AbstractEvent::class)) { |
|
| 34 | 2 | continue; |
|
| 35 | } |
||
| 36 | |||
| 37 | 2 | foreach (array_values($reflection->getConstants()) as $constant) { |
|
| 38 | 2 | if (strlen($constant) < 2) { |
|
| 39 | 2 | continue; |
|
| 40 | } |
||
| 41 | 2 | if (isset($events[$constant])) { |
|
| 42 | throw new Exception( |
||
| 43 | sprintf( |
||
| 44 | 'Event "%s" was already defined in "%s". (%s)', |
||
| 45 | $constant, |
||
| 46 | $events[$constant], |
||
| 47 | $class |
||
| 48 | ) |
||
| 49 | ); |
||
| 50 | } |
||
| 51 | |||
| 52 | 2 | $events[$constant] = [ |
|
| 53 | 2 | 'class' => $class, |
|
| 54 | 2 | 'parameters' => $reflection->getConstructor()->getNumberOfParameters() |
|
| 55 | 2 | ]; |
|
| 56 | 2 | }; |
|
| 57 | 2 | } |
|
| 58 | |||
| 59 | 2 | $this->dumpVariableToCache('events', $events); |
|
| 60 | 2 | } |
|
| 61 | } |
||
| 62 |