Completed
Push — 1.6-dev ( 4f019b )
by Alexis
09:21
created

TestCommand::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 3
Metric Value
c 3
b 1
f 3
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Liip/FunctionalTestBundle
5
 *
6
 * (c) Lukas Kahwe Smith <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Liip\FunctionalTestBundle\Command;
13
14
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
class TestCommand extends ContainerAwareCommand
19
{
20
    private $container;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
21
22
    protected function configure()
23
    {
24
        parent::configure();
25
26
        $this->setName('command:test')
27
            ->setDescription('Test command');
28
    }
29
30
    /**
31
     * @param InputInterface  $input
32
     * @param OutputInterface $output
33
     */
34
    protected function initialize(InputInterface $input, OutputInterface $output)
35
    {
36
        parent::initialize($input, $output);
37
38
        $this->container = $this->getContainer();
39
    }
40
41
    /**
42
     * @param InputInterface  $input
43
     * @param OutputInterface $output
44
     */
45
    protected function execute(InputInterface $input, OutputInterface $output)
46
    {
47
        // Symfony version check
48
        $version = \Symfony\Component\HttpKernel\Kernel::VERSION_ID;
49
        $output->writeln('Symfony version: '.$version);
50
        $output->writeln('Environment: '.$this->container->get('kernel')->getEnvironment());
51
        $output->writeln('Verbosity level set: '.$output->getVerbosity());
52
53
        // Check for the version of Symfony: 20803 is the 2.8
54
        if ($version >= 20803) {
55
            $output->writeln('Environment: '.$this->container->get('kernel')->getEnvironment(), OutputInterface::VERBOSITY_NORMAL);
56
57
            // Write a line with OutputInterface::VERBOSITY_NORMAL (also if this level is set by default by Console)
58
            $output->writeln('Verbosity level: NORMAL', OutputInterface::VERBOSITY_NORMAL);
59
60
            // Write a line with OutputInterface::VERBOSITY_VERBOSE
61
            $output->writeln('Verbosity level: VERBOSE', OutputInterface::VERBOSITY_VERBOSE);
62
63
            // Write a line with OutputInterface::VERBOSITY_VERY_VERBOSE
64
            $output->writeln('Verbosity level: VERY_VERBOSE', OutputInterface::VERBOSITY_VERY_VERBOSE);
65
66
            // Write a line with OutputInterface::VERBOSITY_DEBUG
67
            $output->writeln('Verbosity level: DEBUG', OutputInterface::VERBOSITY_DEBUG);
68
        } else {
69
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) {
70
                $output->writeln('Verbosity level: NORMAL');
71
            }
72
73
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
74
                $output->writeln('Verbosity level: VERBOSE');
75
            }
76
77
            if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
78
                $output->writeln('Verbosity level: VERY_VERBOSE');
79
            }
80
81
            if ($output->getVerbosity() == OutputInterface::VERBOSITY_DEBUG) {
82
                $output->writeln('Verbosity level: DEBUG');
83
            }
84
        }
85
    }
86
}
87