-
Notifications
You must be signed in to change notification settings - Fork 12
/
RoboFile.php
47 lines (36 loc) · 1 KB
/
RoboFile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types = 1);
use Robo\Collection\CollectionBuilder;
use Robo\Tasks;
class RoboFile extends Tasks
{
public function checkAll(): void
{
$this->checkCs();
$this->checkPhpstan();
$this->testUnit();
}
public function checkCs($opts = ['dry-run' => false])
{
$task = $this->taskExec('vendor/bin/php-cs-fixer fix');
$task->arg('--diff');
if ($opts['dry-run']) {
$task->arg('--dry-run');
}
return $this->runAndReturnExitCode($task);
}
public function checkPhpstan()
{
$task = $this->taskExec('vendor/bin/phpstan analyse src --level=max');
return $this->runAndReturnExitCode($task);
}
public function testUnit(): void
{
$this->_exec('vendor/bin/phpunit --bootstrap vendor/autoload.php --testdox tests/');
}
private function runAndReturnExitCode(CollectionBuilder $task)
{
$result = $task->run();
return $result->getExitCode();
}
}