Completed
Push — master ( 515813...89ccca )
by Sergi Tur
03:19
created

Menu   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 77
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 77
loc 77
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getReplacements() 4 4 1
A setReplacements() 4 4 1
A code() 7 7 1
getStubPath() 1 1 ?
obtainReplacements() 1 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 Acacha\AdminLTETemplateLaravel\Console\Menus;
4
5
use Acacha\AdminLTETemplateLaravel\Compiler\StubFileCompiler;
6
use Acacha\AdminLTETemplateLaravel\Console\Routes\GeneratesCode;
7
use Acacha\AdminLTETemplateLaravel\Filesystem\Filesystem;
8
9
/**
10
 * Class Menu.
11
 *
12
 * @package Acacha\AdminLTETemplateLaravel\Console\Menus
13
 */
14 View Code Duplication
abstract class Menu implements GeneratesCode
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...
15
{
16
17
    /**
18
     * Compiler for stub file.
19
     *
20
     * @var StubFileCompiler
21
     */
22
    protected $compiler;
23
24
    /**
25
     * Compiler for stub file.
26
     *
27
     * @var Filesystem
28
     */
29
    protected $filesystem;
30
31
    /**
32
     * Replacements.
33
     *
34
     * @var array
35
     */
36
    protected $replacements;
37
38
    /**
39
     * Route constructor.
40
     *
41
     * @param StubFileCompiler $compiler
42
     * @param Filesystem $filesystem
43
     */
44
    public function __construct(StubFileCompiler $compiler, Filesystem $filesystem)
45
    {
46
        $this->compiler = $compiler;
47
        $this->filesystem = $filesystem;
48
    }
49
50
    /**
51
     * @return array
52
     */
53
    public function getReplacements()
54
    {
55
        return $this->replacements;
56
    }
57
58
    /**
59
     * @param array $replacements
60
     */
61
    public function setReplacements($replacements)
62
    {
63
        $this->replacements = $replacements;
64
    }
65
66
    /**
67
     * Generate route code.
68
     */
69
    public function code()
70
    {
71
        return $this->compiler->compile(
72
            $this->filesystem->get($this->getStubPath()),
73
            $this->obtainReplacements()
74
        );
75
    }
76
77
    /**
78
     * Get stub path.
79
     *
80
     * @return mixed
81
     */
82
    abstract protected function getStubPath();
83
84
    /**
85
     * Obtain replacements for stub.
86
     *
87
     * @return mixed
88
     */
89
    abstract protected function obtainReplacements();
90
}
91