Completed
Pull Request — master (#1)
by Tim
04:03 queued 01:38
created

RoboFile.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 2015 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/appserver-io/robo-tasks
18
 * @link      http://www.appserver.io
19
 */
20
21
use AppserverIo\RoboTasks\Base\loadTasks;
22
use AppserverIo\RoboTasks\AbstractRoboFile;
23
24
/**
25
 * Defines the available build tasks.
26
 *
27
 * @author    Tim Wagner <[email protected]>
28
 * @copyright 2015 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/appserver-io/robo-tasks
31
 * @link      http://www.appserver.io
32
 *
33
 * @SuppressWarnings(PHPMD)
34
 */
35
class RoboFile extends AbstractRoboFile
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...
36
{
37
38
    /**
39
     * Load the libraries tasks.
40
     *
41
     * @param \AppserverIo\RoboTasks\Base\loadTasks
42
     */
43
    use loadTasks;
44
45
    /**
46
     * Run's the composer install command.
47
     *
48
     * @return void
49
     */
50
    public function composerInstall()
51
    {
52
        // optimize autoloader with custom path
53
        $this->taskComposerInstall()
54
             ->preferDist()
55
             ->optimizeAutoloader()
56
             ->run();
57
    }
58
59
    /**
60
     * Run's the composer update command.
61
     *
62
     * @return void
63
     */
64
    public function composerUpdate()
65
    {
66
        // optimize autoloader with custom path
67
        $this->taskComposerUpdate()
68
             ->preferDist()
69
             ->optimizeAutoloader()
70
             ->run();
71
    }
72
73
    /**
74
     * Clean up the environment for a new build.
75
     *
76
     * @return void
77
     */
78
    public function clean()
79
    {
80
        $this->taskDeleteDir($this->getTargetDir())->run();
81
    }
82
83
    /**
84
     * Prepare's the environment for a new build.
85
     *
86
     * @return void
87
     */
88
    public function prepare()
89
    {
90
        $this->taskFileSystemStack()
91
             ->mkdir($this->getDistDir())
92
             ->mkdir($this->getTargetDir())
93
             ->mkdir($this->getReportsDir())
94
             ->run();
95
    }
96
97
    /**
98
     * Run's the PHPMD.
99
     *
100
     * @return void
101
     */
102
    public function runMd()
103
    {
104
105
        // run the mess detector
106
        $this->_exec(
107
            sprintf(
108
                '%s/bin/phpmd %s xml phpmd.xml --reportfile %s/reports/pmd.xml --ignore-violations-on-exit',
109
                $this->getVendorDir(),
110
                $this->getSrcDir(),
111
                $this->getTargetDir()
112
            )
113
        );
114
    }
115
116
    /**
117
     * Run's the PHPCPD.
118
     *
119
     * @return void
120
     */
121
    public function runCpd()
122
    {
123
124
        // run the copy past detector
125
        $this->_exec(
126
            sprintf(
127
                '%s/bin/phpcpd %s --log-pmd %s/reports/pmd-cpd.xml',
128
                $this->getVendorDir(),
129
                $this->getSrcDir(),
130
                $this->getTargetDir()
131
            )
132
        );
133
    }
134
135
    /**
136
     * Run's the PHPCodeSniffer.
137
     *
138
     * @return void
139
     */
140
    public function runCs()
141
    {
142
143
        // run the code sniffer
144
        $this->_exec(
145
            sprintf(
146
                '%s/bin/phpcs -n --report-full --extensions=php --standard=phpcs.xml --report-checkstyle=%s/reports/phpcs.xml %s',
147
                $this->getVendorDir(),
148
                $this->getTargetDir(),
149
                $this->getSrcDir()
150
            )
151
        );
152
    }
153
154
    /**
155
     * Run's the PHPUnit tests.
156
     *
157
     * @return void
158
     */
159
    public function runTests()
160
    {
161
162
        // run PHPUnit
163
        $this->taskPHPUnit(sprintf('%s/bin/phpunit', $this->getVendorDir()))
164
             ->configFile('phpunit.xml')
165
             ->run();
166
    }
167
168
    /**
169
     * The complete build process.
170
     *
171
     * @return void
172
     */
173
    public function build()
174
    {
175
        $this->clean();
176
        $this->prepare();
177
        $this->runCs();
178
        $this->runCpd();
179
        $this->runMd();
180
        $this->runTests();
181
    }
182
}
183