Completed
Push — master ( b43fc2...30080a )
by Gilmar
21:59
created

ScreenplayCommand::runIfExists()   A

Complexity

Conditions 2
Paths 4

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 2
eloc 7
nc 4
nop 3
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 Closure;
18
use Symfony\Component\Console\Input\InputArgument;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21
22
/**
23
 * @codeCoverageIgnore
24
 */
25
class ScreenplayCommand extends AbstractCommand
26
{
27
    protected $list = ['all', 'productPostSimple','productPostMultiple', 'productUpdate',
28
        'productUpdateFull'];
29
30
    protected function runIfExists($name, $input, $output)
31
    {
32
       try {
33
           $c = $this->getApp()->find($name);
34
           $this->sendInfo('<fg=cyan>'.$name.'</fg=cyan>()');
0 ignored issues
show
Bug introduced by
The method sendInfo() does not seem to exist on object<Gpupo\NetshoesSdk...mand\ScreenplayCommand>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
36
           return $c->run($input, $output);
37
       } catch (\Exception $e) {
38
           $this->getLogger()->addDebug($e->getMessage());
0 ignored issues
show
Bug introduced by
The method getLogger() does not seem to exist on object<Gpupo\NetshoesSdk...mand\ScreenplayCommand>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
       }
40
   }
41
42
   public function all($app)
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
   {
44
      $this->getApp()->appendCommand('screenplay:run', 'Run all');
45
   }
46
47 View Code Duplication
    public function productPostSimple($app)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        $this->getApp()->appendCommand('screenplay:product:post:simple', '')
50
            ->setCode(function (InputInterface $input, OutputInterface $output) use ($app) {
51
                $list = $app->processInputParameters([], $input, $output);
0 ignored issues
show
Unused Code introduced by
$list 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...
52
                $output->writeln('Cadastro de quatro produtos contendo apenas um Sku');
53
54
55
                throw new \Exception("Implementar!");
56
            });
57
    }
58
59 View Code Duplication
    public function productPostMultiple($app)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
    {
61
        $this->getApp()->appendCommand('screenplay:product:post:multiple', '')
62
            ->setCode(function (InputInterface $input, OutputInterface $output) use ($app) {
63
                $list = $app->processInputParameters([], $input, $output);
0 ignored issues
show
Unused Code introduced by
$list 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...
64
                $output->writeln('Cadastro de quatro produtos contendo mais de um Sku');
65
66
                throw new \Exception("Implementar!");
67
            });
68
    }
69
70 View Code Duplication
    public function productUpdate($app)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
    {
72
        $this->getApp()->appendCommand('screenplay:product:update', '')
73
            ->setCode(function (InputInterface $input, OutputInterface $output) use ($app) {
74
                $list = $app->processInputParameters([], $input, $output);
0 ignored issues
show
Unused Code introduced by
$list 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...
75
                $output->writeln('Atualizar parcialmente no mínimo quatro produtos criados. As alterações devem incluir department, productType e attibutes');
76
77
                throw new \Exception("Implementar!");
78
            });
79
    }
80
81
82 View Code Duplication
    public function productUpdateFull($app)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
83
    {
84
        $this->getApp()->appendCommand('screenplay:product:update:full', '')
85
            ->setCode(function (InputInterface $input, OutputInterface $output) use ($app) {
86
                $list = $app->processInputParameters([], $input, $output);
0 ignored issues
show
Unused Code introduced by
$list 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...
87
                $output->writeln('Atualizar três produtos cadastrados. As atualizações devem mudar o produto por completo exceto ID e SKU');
88
89
                throw new \Exception("Implementar!");
90
            });
91
    }
92
93
}
94