Completed
Push — master ( 023ae7...9901a6 )
by Fumio
03:37
created

MailMakeCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 77
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 77
loc 77
ccs 13
cts 13
cp 1
rs 10
wmc 4
lcom 0
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A getDefaultNamespace() 4 4 1
A getStub() 4 4 1
A generateFile() 9 9 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 LaravelPlus\Extension\Generators\Console;
4
5
use Jumilla\Generators\Laravel\OneFileGeneratorCommand as BaseCommand;
6
use Jumilla\Generators\FileGenerator;
7
use LaravelPlus\Extension\Addons\Addon;
8
use LaravelPlus\Extension\Generators\GeneratorCommandTrait;
9
10 View Code Duplication
class MailMakeCommand extends BaseCommand
0 ignored issues
show
Duplication introduced by Fumio Furukawa
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...
11
{
12
    use GeneratorCommandTrait;
13
14
    /**
15
     * The console command singature.
16
     *
17
     * @var string
18
     */
19
    protected $signature = 'make:event
20
        {name : The name of the class}
21
        {--a|addon= : The name of the addon}
22
    ';
23
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = '[+] Create a new email class';
30
31
    /**
32
     * The type of class being generated.
33
     *
34
     * @var string
35
     */
36
    protected $type = 'Mail';
37
38
    /**
39
     * The constructor.
40
     */
41 5
    public function __construct()
42
    {
43 5
        parent::__construct();
44
45 5
        $this->setStubDirectory(__DIR__.'/../stubs');
46 5
    }
47
48
    /**
49
     * Get the default namespace for the class.
50
     *
51
     * @return string
52
     */
53 2
    protected function getDefaultNamespace()
54
    {
55 2
        return $this->getRootNamespace().'\\Mail';
56
    }
57
58
    /**
59
     * Get the stub file for the generator.
60
     *
61
     * @return string
62
     */
63 2
    protected function getStub()
64
    {
65 2
        return 'mail.stub';
66
    }
67
68
    /**
69
     * Generate file.
70
     *
71
     * @param \Jumilla\Generators\FileGenerator $generator
72
     * @param string $path
73
     * @param string $fqcn
74
     *
75
     * @return bool
76
     */
77 2
    protected function generateFile(FileGenerator $generator, $path, $fqcn)
78
    {
79 2
        list($namespace, $class) = $this->splitFullQualifyClassName($fqcn);
80
81 2
        return $generator->file($path)->template($this->getStub(), [
82 2
            'namespace' => $namespace,
83 2
            'class' => $class,
84
        ]);
85
    }
86
}
87