Completed
Push — master ( a3830f...527f9f )
by Tim
9s
created

RoboFile::runCs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
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-bundle
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-bundle
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
        'webapp.name' => 'import-cli-simple',
51
        'webapp.version' => '1.0.0-alpha5'
52
    );
53
54
    /**
55
     * Run's the composer install command.
56
     *
57
     * @return void
58
     */
59
    public function composerInstall()
60
    {
61
        // optimize autoloader with custom path
62
        $this->taskComposerInstall()
63
             ->preferDist()
64
             ->optimizeAutoloader()
65
             ->run();
66
    }
67
68
    /**
69
     * Run's the composer update command.
70
     *
71
     * @return void
72
     */
73
    public function composerUpdate()
74
    {
75
        // optimize autoloader with custom path
76
        $this->taskComposerUpdate()
77
             ->preferDist()
78
             ->optimizeAutoloader()
79
             ->run();
80
    }
81
82
    /**
83
     * Clean up the environment for a new build.
84
     *
85
     * @return void
86
     */
87
    public function clean()
88
    {
89
        $this->taskDeleteDir($this->properties['target.dir'])->run();
90
    }
91
92
    /**
93
     * Prepare's the environment for a new build.
94
     *
95
     * @return void
96
     */
97
    public function prepare()
98
    {
99
        $this->taskFileSystemStack()
100
             ->mkdir($this->properties['dist.dir'])
101
             ->mkdir($this->properties['target.dir'])
102
             ->mkdir(sprintf('%s/reports', $this->properties['target.dir']))
103
             ->run();
104
    }
105
106
    /**
107
     * Run's the PHPMD.
108
     *
109
     * @return void
110
     */
111 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...
112
    {
113
114
        // run the mess detector
115
        $this->_exec(
116
            sprintf(
117
                '%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit',
118
                $this->properties['vendor.dir'],
119
                $this->properties['src.dir'],
120
                $this->properties['target.dir']
121
            )
122
        );
123
    }
124
125
    /**
126
     * Run's the PHPCPD.
127
     *
128
     * @return void
129
     */
130 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...
131
    {
132
133
        // run the copy past detector
134
        $this->_exec(
135
            sprintf(
136
                '%s/bin/phpcpd %s --log-pmd %s/reports/pmd-cpd.xml',
137
                $this->properties['vendor.dir'],
138
                $this->properties['src.dir'],
139
                $this->properties['target.dir']
140
            )
141
        );
142
    }
143
144
    /**
145
     * Run's the PHPCodeSniffer.
146
     *
147
     * @return void
148
     */
149 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...
150
    {
151
152
        // run the code sniffer
153
        $this->_exec(
154
            sprintf(
155
                '%s/bin/phpcs -n --extensions=php --standard=psr2 --report-full --report-checkstyle=%s/reports/phpcs.xml %s',
156
                $this->properties['vendor.dir'],
157
                $this->properties['target.dir'],
158
                $this->properties['src.dir']
159
            )
160
        );
161
    }
162
163
    /**
164
     * Run's the PHPUnit tests.
165
     *
166
     * @return void
167
     */
168
    public function runTests()
169
    {
170
171
        // run PHPUnit
172
        $this->taskPHPUnit(sprintf('%s/bin/phpunit', $this->properties['vendor.dir']))
173
             ->configFile('phpunit.xml')
174
             ->run();
175
    }
176
177
    /**
178
     * The complete build process.
179
     *
180
     * @return void
181
     */
182
    public function build()
183
    {
184
        $this->clean();
185
        $this->prepare();
186
        $this->runCs();
187
        $this->runCpd();
188
        $this->runMd();
189
        $this->runTests();
190
    }
191
}
192