Completed
Push — master ( 9919f9...1d1ba6 )
by Anton
09:31
created

AbstractGenerateCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 18.33 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 11
loc 60
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
verify() 0 1 ?
A addModelArgument() 11 11 1
A getTemplate() 0 5 1
A getControllerPath() 0 7 1
A getViewPath() 0 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @copyright Bluz PHP Team
4
 * @link https://github.com/bluzphp/bluzman
5
 */
6
7
namespace Bluzman\Command\Generate;
8
9
use Bluz\Validator\Validator as v;
10
use Bluzman\Command\AbstractCommand;
11
use Bluzman\Input\InputArgument;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
/**
16
 * AbstractCommand
17
 *
18
 * @package  Bluzman\Command\Generate
19
 */
20
abstract class AbstractGenerateCommand extends AbstractCommand
21
{
22
    /**
23
     * @param InputInterface $input
24
     * @param OutputInterface $output
25
     * @return mixed
26
     */
27
    abstract public function verify(InputInterface $input, OutputInterface $output);
28
29
    /**
30
     * addModelArguments
31
     *
32
     * @return self
33
     */
34 14 View Code Duplication
    protected function addModelArgument()
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...
35
    {
36 14
        $model = new InputArgument('model', InputArgument::REQUIRED, 'Model name is required');
37 14
        $model->setValidator(
38 14
            v::string()->alphaNumeric()->noWhitespace()
39
        );
40
41 14
        $this->getDefinition()->addArgument($model);
42
43 14
        return $this;
44
    }
45
46
    /**
47
     * Required for correct mock it
48
     *
49
     * @param  string $class
50
     * @return mixed
51
     */
52
    protected function getTemplate($class)
53
    {
54
        $class = '\\Bluzman\\Generator\\Template\\' . $class;
55
        return new $class;
56
    }
57
58
    /**
59
     * @return string
60
     */
61 2
    protected function getControllerPath($module, $controller)
62
    {
63 2
        return $this->getApplication()->getModulePath($module)
64 2
            . DS . 'controllers'
65 2
            . DS . $controller
66 2
            . '.php';
67
    }
68
69
    /**
70
     * @return string
71
     */
72 1
    protected function getViewPath($module, $controller)
73
    {
74 1
        return $this->getApplication()->getModulePath($module)
75 1
            . DS . 'views'
76 1
            . DS . $controller
77 1
            . '.phtml';
78
    }
79
}
80