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