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

RebuildHook   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A executeBeforeFirstTest() 0 12 2
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