Completed
Push — master ( 9da17b...7475e6 )
by Gilmar
22:57
created

ProductCommand::append()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 24
rs 8.9713
cc 1
eloc 14
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of gpupo/netshoes-sdk
5
 * Created by Gilmar Pupo <[email protected]>
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 * For more information, see <http://www.g1mr.com/>.
9
 */
10
namespace Gpupo\NetshoesSdk\Console\Command;
11
12
use Gpupo\NetshoesSdk\Console\Application;
13
use Symfony\Component\Console\Input\InputArgument;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
class ProductCommand
18
{
19
    public static function append(Application $app)
20
    {
21
        $app->appendCommand('product:view', 'Consulta a situação de um produto')
22
            ->addArgument('productId', InputArgument::REQUIRED, 'Product ID')
23
            ->setCode(function (InputInterface $input, OutputInterface $output) use ($app) {
24
                $list = $app->processInputParameters([], $input, $output);
25
26
            $p = $app->factorySdk($list)->factoryManager('product')->findById($input->getArgument('productId'));
27
28
            $app->displayTableResults($output, [[
29
                'Id'           => $p->getProductId(),
30
                'Brand'        => $p->getBrand(),
31
                'Department'   => $p->getDepartment(),
32
                'Product Type' => $p->getProductType(),
33
            ]]);
34
35
            $output->writeln('<fg=yellow>Skus</>');
36
37
            $app->displayTableResults($output, $p->getSkus());
38
39
        });
40
41
        return $app;
42
    }
43
}
44