|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * Copyright (c) 2021-2023 Andreas Möller |
| 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/ergebnis/phpunit-slow-test-detector |
| 12 | + */ |
| 13 | + |
| 14 | +namespace Ergebnis\PHPUnit\SlowTestDetector; |
| 15 | + |
| 16 | +/** |
| 17 | + * @internal |
| 18 | + */ |
| 19 | +final class Phase |
| 20 | +{ |
| 21 | + private PhaseIdentifier $phaseIdentifier; |
| 22 | + private Time $startTime; |
| 23 | + private Time $stopTime; |
| 24 | + private Duration $duration; |
| 25 | + |
| 26 | + private function __construct( |
| 27 | + PhaseIdentifier $phaseIdentifier, |
| 28 | + Time $startTime, |
| 29 | + Time $stopTime, |
| 30 | + Duration $duration |
| 31 | + ) { |
| 32 | + $this->phaseIdentifier = $phaseIdentifier; |
| 33 | + $this->startTime = $startTime; |
| 34 | + $this->stopTime = $stopTime; |
| 35 | + $this->duration = $duration; |
| 36 | + } |
| 37 | + |
| 38 | + public static function create( |
| 39 | + PhaseIdentifier $phaseIdentifier, |
| 40 | + Time $startTime, |
| 41 | + Time $stopTime |
| 42 | + ): self { |
| 43 | + return new self( |
| 44 | + $phaseIdentifier, |
| 45 | + $startTime, |
| 46 | + $stopTime, |
| 47 | + $stopTime->duration($startTime), |
| 48 | + ); |
| 49 | + } |
| 50 | + |
| 51 | + public function phaseIdentifier(): PhaseIdentifier |
| 52 | + { |
| 53 | + return $this->phaseIdentifier; |
| 54 | + } |
| 55 | + |
| 56 | + public function startTime(): Time |
| 57 | + { |
| 58 | + return $this->startTime; |
| 59 | + } |
| 60 | + |
| 61 | + public function stopTime(): Time |
| 62 | + { |
| 63 | + return $this->stopTime; |
| 64 | + } |
| 65 | + |
| 66 | + public function duration(): Duration |
| 67 | + { |
| 68 | + return $this->duration; |
| 69 | + } |
| 70 | +} |
0 commit comments