CheckCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 11 1
A execute() 0 17 4
1
<?php
2
/**
3
 * Magento Version Identification
4
 *
5
 * PHP version 5
6
 *
7
 * @author    Steve Robbins <[email protected]>
8
 * @copyright 2015 Steve Robbins
9
 * @license   http://creativecommons.org/licenses/by/4.0/ CC BY 4.0
10
 * @link      https://github.com/steverobbins/magento-version-identification-php
11
 */
12
13
namespace Mvi\Command;
14
15
use Mvi\Command\MviCommand;
16
use Mvi\Check;
17
use Symfony\Component\Console\Input\InputArgument;
18
use Symfony\Component\Console\Input\InputInterface;
19
use Symfony\Component\Console\Output\OutputInterface;
20
21
/**
22
 * Checks the edition and version of a URL
23
 */
24
class CheckCommand extends MviCommand
25
{
26
    /**
27
     * Configure check command
28
     *
29
     * @return void
30
     */
31
    protected function configure()
32
    {
33
        $this
34
            ->setName('check')
35
            ->setDescription('Check site\'s Magento version')
36
            ->addArgument(
37
                'url',
38
                InputArgument::REQUIRED,
39
                'The URL of the Magento application'
40
            );
41
    }
42
43
    /**
44
     * Run check command
45
     *
46
     * @param InputInterface  $input
47
     * @param OutputInterface $output
48
     *
49
     * @return void
50
     */
51
    protected function execute(InputInterface $input, OutputInterface $output)
52
    {
53
        $checker = new Check($input->getArgument('url'));
54
        $info    = $checker->getInfo();
55
        if ($info === false) {
56
            $output->writeln('<error>Unable to retrieve Magento information</error>');
57
            return;
58
        }
59
        $i = 0;
60
        foreach ($info as $edition => $versions) {
61
            $output->writeln(sprintf('Edition: <info>%s</info>', $edition));
62
            $output->writeln(sprintf('Version: <info>%s</info>', implode(', ', $versions)));
63
            if ($i++ > 0) {
64
                $output->writeln('OR');
65
            }
66
        }
67
    }
68
}
69