Completed
Push — master ( 466032...5da320 )
by Marco
02:49
created

StopEventListener   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 21
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A listen() 0 17 2
1
<?php namespace Comodojo\Foundation\Console;
2
3
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
4
5
/**
6
 * @package     Comodojo Foundation
7
 * @author      Marco Giovinazzi <[email protected]>
8
 * @license     MIT
9
 *
10
 * LICENSE:
11
 *
12
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18
 * THE SOFTWARE.
19
 */
20
21
class StopEventListener {
22
23
    static public function listen(ConsoleTerminateEvent $event) {
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
24
25
        $command = $event->getCommand();
26
        $name = $command->getName();
27
        $output = $event->getOutput();
28
        $output->writeln("");
29
30
        if ( $command instanceof AbstractCommand ) {
31
32
            $logger = $command->getLogger();
33
            $time = number_format($command->getEndTime(), 2);
34
35
            $logger->notice("Command $name tooks $time secs");
36
37
        }
38
39
    }
40
41
}
42