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

StartEventListener   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
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 27
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A listen() 0 23 2
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