MakeFactoryCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 4
c 3
b 0
f 1
lcom 0
cbo 1
dl 68
loc 68
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getStub() 8 8 2
A getDefaultNamespace() 4 4 1
A getOptions() 6 6 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
namespace R\Hive\Commands;
4
5
use Symfony\Component\Console\Input\InputOption;
6
7 View Code Duplication
class MakeFactoryCommand extends HiveGeneratorCommand
0 ignored issues
show
Duplication introduced by
This class 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...
8
{
9
    /**
10
     * The console command name.
11
     *
12
     * @var string
13
     */
14
    protected $name = 'hive:factory';
15
16
    /**
17
     * The console command description.
18
     *
19
     * @var string
20
     */
21
    protected $description = 'Create a new Hive factory class.';
22
23
    /**
24
     * The type of class being generated.
25
     *
26
     * @var string
27
     */
28
    protected $type = 'Factory';
29
30
    /**
31
     * The compound command to fire after the parent succeeds.
32
     *
33
     * @var string
34
     */
35
    protected $compound = 'validator';
36
37
    /**
38
     * Get the stub file for the generator.
39
     *
40
     * @return string
41
     */
42
    protected function getStub()
43
    {
44
        if ($this->option('validator')) {
45
            return __DIR__.'/stubs/factory-validator.stub';
46
        } else {
47
            return __DIR__.'/stubs/factory-no-validator.stub';
48
        }
49
    }
50
51
    /**
52
     * Get the default namespace for the class.
53
     *
54
     * @param string $rootNamespace
55
     *
56
     * @return string
57
     */
58
    protected function getDefaultNamespace($rootNamespace)
59
    {
60
        return $rootNamespace.'\Lib\Factories';
61
    }
62
63
    /**
64
     * Get the console command options.
65
     *
66
     * @return array
67
     */
68
    protected function getOptions()
69
    {
70
        return [
71
            ['validator', 'i', InputOption::VALUE_NONE, 'Create a new associated validator.'],
72
        ];
73
    }
74
}
75