Extension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 31
ccs 0
cts 14
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A bootstrap() 0 29 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Copyright (c) 2024 TEQneers GmbH & Co. KG
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE.md file that was distributed with this source code.
10
 *
11
 * @see https://github.com/teqneers/phpunit-stopwatch
12
 */
13
14
namespace TQ\Testing\Extension\Stopwatch;
15
16
use PHPUnit\Runner;
17
use PHPUnit\TextUI;
18
use TQ\Testing\Extension\Stopwatch\Subscriber\ReportTest;
19
use TQ\Testing\Extension\Stopwatch\Subscriber\ReportTestClassSetUp;
20
use TQ\Testing\Extension\Stopwatch\Subscriber\ReportTestClassTearDown;
21
use TQ\Testing\Extension\Stopwatch\Subscriber\ResetForTest;
22
use TQ\Testing\Extension\Stopwatch\Subscriber\ResetForTestClassSetUp;
23
use TQ\Testing\Extension\Stopwatch\Subscriber\ResetForTestClassTearDown;
24
use TQ\Testing\Extension\Stopwatch\Subscriber\TestStart;
25
use TQ\Testing\Extension\Stopwatch\Subscriber\TestStop;
26
use TQ\Testing\Extension\Stopwatch\Subscriber\TotalReport;
27
28
/**
29
 * @psalm-api
30
 */
31
final class Extension implements Runner\Extension\Extension
32
{
33
    public function bootstrap(
34
        TextUI\Configuration\Configuration $configuration,
35
        Runner\Extension\Facade $facade,
36
        Runner\Extension\ParameterCollection $parameters,
37
    ): void {
38
        //        $facade->registerTracer(
39
        //            new class implements Tracer {
40
        //                public function trace(\PHPUnit\Event\Event $event): void
41
        //                {
42
        //                    $lines = explode(PHP_EOL, $event->asString());
43
        //                    echo "\nEVENT: ".implode(' ', $lines).PHP_EOL.PHP_EOL;
44
        //                }
45
        //            }
46
        //        );
47
48
        $reporter  = new Reporter\DefaultReporter();
49
        $stopwatch = new TimingCollector();
50
        Stopwatch::init($stopwatch);
51
52
        $facade->registerSubscribers(
53
            new TestStart($stopwatch),
54
            new TestStop($stopwatch),
55
            new ResetForTestClassSetUp($stopwatch),
56
            new ResetForTest($stopwatch),
57
            new ResetForTestClassTearDown($stopwatch),
58
            new ReportTestClassSetUp($stopwatch, $reporter),
59
            new ReportTestClassTearDown($stopwatch, $reporter),
60
            new ReportTest($stopwatch, $reporter),
61
            new TotalReport($stopwatch, $reporter),
62
        );
63
    }
64
}
65