Passed
Pull Request — master (#42)
by Dmitriy
12:32
created

RebuildHook::executeBeforeFirstTest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Composer\Config\Tests\Integration;
6
7
use PHPUnit\Runner\BeforeFirstTestHook;
8
use Yiisoft\Composer\Config\Builder;
9
use Yiisoft\Composer\Config\Util\PathHelper;
10
11
final class RebuildHook implements BeforeFirstTestHook
12
{
13
    public function executeBeforeFirstTest(): void
14
    {
15
        if (!(bool) ($_SERVER['REBUILD'] ?? false)) {
16
            return;
17
        }
18
        $directory = PathHelper::realpath(__DIR__) . '/Environment';
19
20
        echo "Changing CWD to {$directory}" . PHP_EOL;
21
        chdir($directory);
22
23
        require_once 'vendor/autoload.php';
24
        Builder::rebuild();
25
    }
26
}
27