Passed
Push — master ( 7b51e3...1d4e8b )
by Tim
07:18
created

RoboFile   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 157
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 49
c 1
b 0
f 0
dl 0
loc 157
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A composerUpdate() 0 7 1
A runCpd() 0 10 1
A runMd() 0 10 1
A runCs() 0 10 1
A prepare() 0 7 1
A clean() 0 3 1
A runTests() 0 7 1
A composerInstall() 0 7 1
A build() 0 13 1
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 2019 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-attribute-set
18
 * @link      http://www.techdivision.com
19
 */
20
21
use Lurker\Event\FilesystemEvent;
0 ignored issues
show
Bug introduced by
The type Lurker\Event\FilesystemEvent was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
use Symfony\Component\Finder\Finder;
23
24
/**
25
 * Defines the available build tasks.
26
 *
27
 * @author    Tim Wagner <[email protected]>
28
 * @copyright 2019 TechDivision GmbH <[email protected]>
29
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
30
 * @link      https://github.com/techdivision/import-attribute-set
31
 * @link      http://www.techdivision.com
32
 *
33
 * @SuppressWarnings(PHPMD)
34
 */
35
class RoboFile extends \Robo\Tasks
36
{
37
38
    /**
39
     * The build properties.
40
     *
41
     * @var array
42
     */
43
    protected $properties = array(
44
        'base.dir' => __DIR__,
45
        'src.dir' => __DIR__ . '/src',
46
        'dist.dir' => __DIR__ . '/dist',
47
        'vendor.dir' => __DIR__ . '/vendor',
48
        'target.dir' => __DIR__ . '/target'
49
    );
50
51
    /**
52
     * Run's the composer install command.
53
     *
54
     * @return \Robo\Result The result
55
     */
56
    public function composerInstall()
57
    {
58
        // optimize autoloader with custom path
59
        return $this->taskComposerInstall()
60
             ->preferDist()
61
             ->optimizeAutoloader()
62
             ->run();
63
    }
64
65
    /**
66
     * Run's the composer update command.
67
     *
68
     * @return \Robo\Result The result
69
     */
70
    public function composerUpdate()
71
    {
72
        // optimize autoloader with custom path
73
        return $this->taskComposerUpdate()
74
             ->preferDist()
75
             ->optimizeAutoloader()
76
             ->run();
77
    }
78
79
    /**
80
     * Clean up the environment for a new build.
81
     *
82
     * @return \Robo\Result The result
83
     */
84
    public function clean()
85
    {
86
        return $this->taskDeleteDir($this->properties['target.dir'])->run();
87
    }
88
89
    /**
90
     * Prepare's the environment for a new build.
91
     *
92
     * @return \Robo\Result The result
93
     */
94
    public function prepare()
95
    {
96
        return $this->taskFileSystemStack()
97
             ->mkdir($this->properties['dist.dir'])
98
             ->mkdir($this->properties['target.dir'])
99
             ->mkdir(sprintf('%s/reports', $this->properties['target.dir']))
100
             ->run();
101
    }
102
103
    /**
104
     * Run's the PHPMD.
105
     *
106
     * @return \Robo\Result The result
107
     */
108
    public function runMd()
109
    {
110
111
        // run the mess detector
112
        return $this->_exec(
113
            sprintf(
114
                '%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit',
115
                $this->properties['vendor.dir'],
116
                $this->properties['src.dir'],
117
                $this->properties['target.dir']
118
            )
119
        );
120
    }
121
122
    /**
123
     * Run's the PHPCPD.
124
     *
125
     * @return \Robo\Result The result
126
     */
127
    public function runCpd()
128
    {
129
130
        // run the copy past detector
131
        return $this->_exec(
132
            sprintf(
133
                '%s/bin/phpcpd %s --exclude Utils --log-pmd %s/reports/pmd-cpd.xml',
134
                $this->properties['vendor.dir'],
135
                $this->properties['src.dir'],
136
                $this->properties['target.dir']
137
            )
138
        );
139
    }
140
141
    /**
142
     * Run's the PHPCodeSniffer.
143
     *
144
     * @return \Robo\Result The result
145
     */
146
    public function runCs()
147
    {
148
149
        // run the code sniffer
150
        return $this->_exec(
151
            sprintf(
152
                '%s/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml --report-checkstyle=%s/reports/phpcs.xml %s',
153
                $this->properties['vendor.dir'],
154
                $this->properties['target.dir'],
155
                $this->properties['src.dir']
156
            )
157
        );
158
    }
159
160
    /**
161
     * Run's the PHPUnit tests.
162
     *
163
     * @return \Robo\Result The result
164
     */
165
    public function runTests()
166
    {
167
168
        // run PHPUnit
169
        return $this->taskPHPUnit(sprintf('%s/bin/phpunit', $this->properties['vendor.dir']))
170
             ->configFile('phpunit.xml')
171
             ->run();
172
    }
173
174
    /**
175
     * The complete build process.
176
     *
177
     * @return void
178
     */
179
    public function build()
180
    {
181
182
        // stop the build on first failure of a task
183
        $this->stopOnFail(true);
184
185
        // process the build
186
        $this->clean();
187
        $this->prepare();
188
        $this->runCs();
189
        $this->runCpd();
190
        $this->runMd();
191
        $this->runTests();
192
    }
193
}
194