Completed
Push — master ( d6c0d3...fbf2bc )
by Sergi Tur
03:14
created

ControllerRoute   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 40
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getStubPath() 4 4 1
A obtainReplacements() 8 8 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\Routes;
4
5
use Acacha\AdminLTETemplateLaravel\Compiler\StubFileCompiler;
6
use Acacha\AdminLTETemplateLaravel\Filesystem\Filesystem;
7
8
/**
9
 * Class ControllerRoute.
10
 *
11
 * @package Acacha\AdminLTETemplateLaravel\Console
12
 */
13 View Code Duplication
class ControllerRoute extends Route
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...
14
{
15
    use Controller;
16
17
    /**
18
     * Route constructor.
19
     *
20
     * @param StubFileCompiler $compiler
21
     * @param Filesystem $filesystem
22
     */
23
    public function __construct(StubFileCompiler $compiler,Filesystem $filesystem)
24
    {
25
        parent::__construct($compiler,$filesystem);
26
    }
27
28
    /**
29
     * Get stub path.
30
     *
31
     * @return mixed
32
     */
33
    protected function getStubPath()
34
    {
35
        return __DIR__ . '/../stubs/route_with_controller.stub';
36
    }
37
38
    /**
39
     * Obtain replacements.
40
     *
41
     * @return array
42
     */
43
    protected function obtainReplacements()
44
    {
45
        return [
46
            'ROUTE_LINK' => $this->getReplacements()[0],
47
            'ROUTE_CONTROLLER' => $this->controller($this->getReplacements()[1]),
48
            'ROUTE_METHOD' => $this->getReplacements()[2],
49
        ];
50
    }
51
52
}
53