Completed
Push — master ( 6367b5...e868c1 )
by Gilmar
25:44 queued 01:46
created

OrderCommand::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
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 20
rs 9.4285
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 information of copyright and license you should read the file
7
 * LICENSE which is distributed with this source code.
8
 * Para a informação dos direitos autorais e de licença você deve ler o arquivo
9
 * LICENSE que é distribuído com este código-fonte.
10
 * Para obtener la información de los derechos de autor y la licencia debe leer
11
 * el archivo LICENSE que se distribuye con el código fuente.
12
 * For more information, see <http://www.g1mr.com/>.
13
 */
14
15
namespace Gpupo\NetshoesSdk\Console\Command;
16
17
use Symfony\Component\Console\Input\InputArgument;
18
use Symfony\Component\Console\Input\InputInterface;
19
use Symfony\Component\Console\Output\OutputInterface;
20
use Gpupo\NetshoesSdk\Entity\Order\Order;
21
22
class OrderCommand extends AbstractCommand
23
{
24
    protected $list = ['view', 'update'];
25
26
    /**
27
     * @codeCoverageIgnore
28
     */
29
    protected function update($app)
30
    {
31
        $insertOptions = [
32
            ['key' => 'file'],
33
        ];
34
35
        $this->getApp()->appendCommand('order:update:to:invoiced', 'Move um pedido para a situação [Invoiced]')
36
        ->addArgument('orderId', InputArgument::REQUIRED, 'Product ID')
37
        ->setCode(function (InputInterface $input, OutputInterface $output) use ($app, $insertOptions) {
38
            $list = $app->processInputParameters($insertOptions, $input, $output);
39
            $id = $input->getArgument('orderId');
0 ignored issues
show
Unused Code introduced by
$id is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
40
            $data = json_decode(file_get_contents($list['file']), true);
41
            $sdk = $app->factorySdk($list);
42
            $manager = $sdk->factoryManager('order');
43
            $order = $sdk->createOrder($data);
44
            $order->setOrderStatus('invoiced');
45
46
            $manager->updateStatus($order);
47
        });
48
    }
49
50
    /**
51
     * @codeCoverageIgnore
52
     */
53
    protected function view($app)
54
    {
55
        $this->getApp()->appendCommand('order:view', 'Mostra detalhes de um pedido')
56
            ->addArgument('orderId', InputArgument::REQUIRED, 'Product ID')
57
            ->setCode(function (InputInterface $input, OutputInterface $output) use ($app) {
58
                $list = $app->processInputParameters([], $input, $output);
59
                $id = $input->getArgument('orderId');
60
                $p = $app->factorySdk($list)->factoryManager('order')->findById($id);
61
62
                $output->writeln('Order #<comment>'.$id.'</comment>');
63
                $app->displayTableResults($output, [$p->toLog()]);
64
                $output->writeln('Shipping - Order #<comment>'.$id.'</comment>');
65
                $app->displayTableResults($output, [$p->getShipping()->toLog()]);
66
67
                $output->writeln('Shipping Items - Order #<comment>'.$id.'</comment>');
68
                $app->displayTableResults($output, $p->getShipping()->getItems()->toLog());
69
            });
70
    }
71
72
}
73