ObserversCommand::actionIndex()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Ship\Command;
4
5
use Rudra\EventDispatcher\EventDispatcherFacade as EventDispatcher;
6
7
class ObserversCommand
8
{
9
    public function actionIndex(): void
10
    {
11
        $mask = "|%-5.5s |%-20.20s|%-45.45s|%-20.20s| x |" . PHP_EOL;
12
        printf("\e[1;35m" . $mask . "\e[m", " ", "event", "observer", "action");
13
14
        foreach (EventDispatcher::getObservers() as $event => $observer) {
15
            $this->getTable($event, $observer);
16
        }
17
    }
18
19
    protected function getTable($event, array $data): void
20
    {
21
        $mask = "|%-5.5s |%-20.20s|%-45.45s|%-20.20s| x |" . PHP_EOL;
22
        $i    = 1;
23
24
        foreach ($data as $subscriber => $method) {
25
            printf("\e[5;36m" . $mask . "\e[m", $i, $event, $subscriber, $method);
26
            $i++;
27
        }
28
    }
29
}
30