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

StartEventListener::listen()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 16
cp 0
rs 9.0856
c 0
b 0
f 0
cc 2
eloc 13
nc 2
nop 1
crap 6
1
<?php namespace Comodojo\Foundation\Console;
2
3
use Symfony\Component\Console\Event\ConsoleCommandEvent;
4
use Symfony\Component\Console\Logger\ConsoleLogger;
5
6
/**
7
 * @package     Comodojo Foundation
8
 * @author      Marco Giovinazzi <[email protected]>
9
 * @license     MIT
10
 *
11
 * LICENSE:
12
 *
13
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
 * THE SOFTWARE.
20
 */
21
22
class StartEventListener {
23
24
    static public function listen(ConsoleCommandEvent $event) {
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
25
26
        $output = $event->getOutput();
27
        $command = $event->getCommand();
28
        $application = $command->getApplication();
29
30
        if ( $command instanceof AbstractCommand ) {
31
32
            $logger = new ConsoleLogger($output);
33
            $command->setLogger($logger);
34
35
            $command->setStartTime();
36
37
            $output->writeln([
38
                '',
39
                $application->getVersion(),
40
                '-----------------------------',
41
                ''
42
            ]);
43
44
        }
45
46
    }
47
48
}
49