RoboFile::composerInstall()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/**
4
 * RoboFile.php
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-product
18
 * @link      http://www.techdivision.com
19
 */
20
21
use Lurker\Event\FilesystemEvent;
22
23
use Symfony\Component\Finder\Finder;
24
25
/**
26
 * Defines the available build tasks.
27
 *
28
 * @author    Tim Wagner <[email protected]>
29
 * @copyright 2016 TechDivision GmbH <[email protected]>
30
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
31
 * @link      https://github.com/techdivision/import-product
32
 * @link      http://www.techdivision.com
33
 *
34
 * @SuppressWarnings(PHPMD)
35
 */
36
class RoboFile extends \Robo\Tasks
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
37
{
38
39
    /**
40
     * The build properties.
41
     *
42
     * @var array
43
     */
44
    protected $properties = array(
45
        'base.dir' => __DIR__,
46
        'src.dir' => __DIR__ . '/src',
47
        'dist.dir' => __DIR__ . '/dist',
48
        'vendor.dir' => __DIR__ . '/vendor',
49
        'target.dir' => __DIR__ . '/target'
50
    );
51
52
    /**
53
     * Runs the composer install command.
54
     *
55
     * @return void
56
     */
57
    public function composerInstall()
58
    {
59
        // optimize autoloader with custom path
60
        $this->taskComposerInstall()
61
             ->preferDist()
62
             ->optimizeAutoloader()
63
             ->run();
64
    }
65
66
    /**
67
     * Runs the composer update command.
68
     *
69
     * @return void
70
     */
71
    public function composerUpdate()
72
    {
73
        // optimize autoloader with custom path
74
        $this->taskComposerUpdate()
75
             ->preferDist()
76
             ->optimizeAutoloader()
77
             ->run();
78
    }
79
80
    /**
81
     * Clean up the environment for a new build.
82
     *
83
     * @return void
84
     */
85
    public function clean()
86
    {
87
        $this->taskDeleteDir($this->properties['target.dir'])->run();
88
    }
89
90
    /**
91
     * Prepare's the environment for a new build.
92
     *
93
     * @return void
94
     */
95
    public function prepare()
96
    {
97
        $this->taskFileSystemStack()
98
             ->mkdir($this->properties['dist.dir'])
99
             ->mkdir($this->properties['target.dir'])
100
             ->mkdir(sprintf('%s/reports', $this->properties['target.dir']))
101
             ->run();
102
    }
103
104
    /**
105
     * Runs the PHPMD.
106
     *
107
     * @return void
108
     */
109 View Code Duplication
    public function runMd()
0 ignored issues
show
Duplication introduced by
This method 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...
110
    {
111
112
        // run the mess detector
113
        $this->_exec(
114
            sprintf(
115
                '%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit',
116
                $this->properties['vendor.dir'],
117
                $this->properties['src.dir'],
118
                $this->properties['target.dir']
119
            )
120
        );
121
    }
122
123
    /**
124
     * Runs the PHPCPD.
125
     *
126
     * @return void
127
     */
128 View Code Duplication
    public function runCpd()
0 ignored issues
show
Duplication introduced by
This method 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...
129
    {
130
131
        // run the copy paste detector
132
        $this->_exec(
133
            sprintf(
134
                '%s/bin/phpcpd --exclude Observers --log-pmd %s/reports/pmd-cpd.xml %s',
135
                $this->properties['vendor.dir'],
136
                $this->properties['target.dir'],
137
                $this->properties['src.dir']
138
            )
139
        );
140
    }
141
142
    /**
143
     * Runs the PHPCodeSniffer.
144
     *
145
     * @return void
146
     */
147 View Code Duplication
    public function runCs()
0 ignored issues
show
Duplication introduced by
This method 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...
148
    {
149
150
        // run the code sniffer
151
        $this->_exec(
152
            sprintf(
153
                '%s/bin/phpcs -n --extensions=php --standard=phpcs.xml --report-full --report-checkstyle=%s/reports/phpcs.xml %s',
154
                $this->properties['vendor.dir'],
155
                $this->properties['target.dir'],
156
                $this->properties['src.dir']
157
            )
158
        );
159
    }
160
161
    /**
162
     * Runs the PHPUnit tests.
163
     *
164
     * @return void
165
     */
166
    public function runTests()
167
    {
168
169
        // run PHPUnit
170
        $this->taskPHPUnit(sprintf('%s/bin/phpunit', $this->properties['vendor.dir']))
171
             ->configFile('phpunit.xml')
172
             ->run();
173
    }
174
175
    /**
176
     * The complete build process.
177
     *
178
     * @return void
179
     */
180
    public function build()
181
    {
182
        $this->clean();
183
        $this->prepare();
184
        $this->runCs();
185
        $this->runCpd();
186
        $this->runMd();
187
        $this->runTests();
188
    }
189
}
190