CatalogCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 23 3
1
<?php
2
/**
3
 * Mage Scan
4
 *
5
 * PHP version 5
6
 *
7
 * @category  MageScan
8
 * @package   MageScan
9
 * @author    Steve Robbins <[email protected]>
10
 * @copyright 2015 Steve Robbins
11
 * @license   http://creativecommons.org/licenses/by/4.0/ CC BY 4.0
12
 * @link      https://github.com/steverobbins/magescan
13
 */
14
15
namespace MageScan\Command\Scan;
16
17
use MageScan\Check\Catalog;
18
use Symfony\Component\Console\Input\InputInterface;
19
use Symfony\Component\Console\Output\OutputInterface;
20
21
/**
22
 * Scan catalog command
23
 *
24
 * @category  MageScan
25
 * @package   MageScan
26
 * @author    Steve Robbins <[email protected]>
27
 * @copyright 2015 Steve Robbins
28
 * @license   http://creativecommons.org/licenses/by/4.0/ CC BY 4.0
29
 * @link      https://github.com/steverobbins/magescan
30
 */
31
class CatalogCommand extends AbstractCommand
32
{
33
    /**
34
     * Configure command
35
     *
36
     * @return void
37
     */
38
    protected function configure()
39
    {
40
        $this
41
            ->setName('scan:catalog')
42
            ->setDescription('Get catalog information');
43
        parent::configure();
44
    }
45
46
    /**
47
     * Execute command
48
     *
49
     * @param InputInterface  $input
50
     * @param OutputInterface $output
51
     *
52
     * @return void
53
     */
54
    protected function execute(InputInterface $input, OutputInterface $output)
55
    {
56
        $rows     = [];
57
        $catalog  = new Catalog;
58
        $catalog->setRequest($this->request);
59
        $categoryCount = $catalog->categoryCount();
60
        $rows[] = [
61
            'Categories',
62
            $categoryCount !== false ? $categoryCount : 'Unknown'
63
        ];
64
        $productCount = $catalog->productCount();
65
        $rows[] = [
66
            'Products',
67
            $productCount !== false ? $productCount : 'Unknown'
68
        ];
69
        $this->out('Catalog Information', [[
70
            'type' => 'table',
71
            'data' => [
72
                ['Type', 'Count'],
73
                $rows
74
            ]
75
        ]]);
76
    }
77
}
78