Total Complexity | 8 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
6 | class Hercule |
||
7 | { |
||
8 | /** |
||
9 | * @param string[] $events |
||
10 | * @throws \Symfony\Component\Process\Exception\ProcessFailedException |
||
11 | */ |
||
12 | public static function setHandledEvents(array $events): void |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @param string $handledEvent |
||
28 | * @return string[] |
||
29 | */ |
||
30 | public static function findAentsByHandledEvent(string $handledEvent): array |
||
31 | { |
||
32 | $containerProjectDir = Pheromone::getContainerProjectDirectory(); |
||
33 | |||
34 | $aenthillJSONstr = file_get_contents($containerProjectDir . '/aenthill.json'); |
||
35 | $aenthillJSON = \GuzzleHttp\json_decode($aenthillJSONstr, true); |
||
36 | |||
37 | $aents = array(); |
||
38 | if (isset($aenthillJSON['aents'])) { |
||
39 | foreach ($aenthillJSON['aents'] as $aent) { |
||
40 | if (array_key_exists('handled_events', $aent) && \in_array($handledEvent, $aent['handled_events'], true)) { |
||
41 | $aents[] = $aent; |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | return $aents; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Returns true if one of the aents installed can explicitly handle events of type $handledEvent |
||
50 | * |
||
51 | * @param string $handledEvent |
||
52 | * @return bool |
||
53 | */ |
||
54 | public static function canHandleEvent(string $handledEvent): bool |
||
57 | } |
||
58 | } |
||
59 |