Completed
Push — master ( 98a062...441031 )
by Ryan
10:10
created

WriteAddonPhpUnit   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 66
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A handle() 12 12 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 namespace Anomaly\Streams\Platform\Addon\Console\Command;
2
3
use Anomaly\Streams\Platform\Support\Parser;
4
use Illuminate\Filesystem\Filesystem;
5
6
/**
7
 * Class WriteAddonPhpUnit
8
 *
9
 * @link   http://pyrocms.com/
10
 * @author PyroCMS, Inc. <[email protected]>
11
 * @author Ryan Thompson <[email protected]>
12
 */
13 View Code Duplication
class WriteAddonPhpUnit
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
16
    /**
17
     * The addon path.
18
     *
19
     * @var string
20
     */
21
    private $path;
22
23
    /**
24
     * The addon type.
25
     *
26
     * @var string
27
     */
28
    private $type;
29
30
    /**
31
     * The addon slug.
32
     *
33
     * @var string
34
     */
35
    private $slug;
36
37
    /**
38
     * The vendor slug.
39
     *
40
     * @var string
41
     */
42
    private $vendor;
43
44
    /**
45
     * Create a new WriteAddonPhpUnit instance.
46
     *
47
     * @param $path
48
     * @param $type
49
     * @param $slug
50
     * @param $vendor
51
     */
52
    public function __construct($path, $type, $slug, $vendor)
53
    {
54
        $this->path   = $path;
55
        $this->slug   = $slug;
56
        $this->type   = $type;
57
        $this->vendor = $vendor;
58
    }
59
60
    /**
61
     * Handle the command.
62
     *
63
     * @param Parser     $parser
64
     * @param Filesystem $filesystem
65
     */
66
    public function handle(Parser $parser, Filesystem $filesystem)
67
    {
68
        $path = "{$this->path}/phpunit.xml";
69
70
        $template = $filesystem->get(
71
            base_path('vendor/anomaly/streams-platform/resources/stubs/addons/phpunit.stub')
72
        );
73
74
        $filesystem->makeDirectory(dirname($path), 0755, true, true);
75
76
        $filesystem->put($path, $parser->parse($template));
77
    }
78
}
79