Passed
Push — master ( 3988b7...41f5ff )
by Korotkov
01:55 queued 12s
created

ObserversCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A actionIndex() 0 7 2
A getTable() 0 8 2
1
<?php
2
3
namespace App\Ship\Commands;
4
5
use Rudra\EventDispatcher\EventDispatcherFacade as EventDispatcher;
6
7
class ObserversCommand
8
{
9
    public function actionIndex()
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)
20
    {
21
        $mask = "|%-5.5s |%-20.20s|%-45.45s|%-20.20s| x |" . PHP_EOL;
22
        $i    = 1;
23
24
        foreach ($data as $name => $observer) {
25
            printf("\e[5;36m" . $mask . "\e[m", $i, $event, $observer["subscriber"], $observer["method"]);
26
            $i++;
27
        }
28
    }
29
}
30