Lines
100.00%
7 / 7
Methods
100.00%
2 / 2
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| fromScriptOutput | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 3 | ||
| 10 | final readonly class PreparedRelease | |
| 11 | { | |
| 12 | public function __construct( | |
| 13 | public CommitId $commit, | |
| 14 | public ReleaseState $state, | |
| 15 | ) {} | |
| 16 | ||
| 17 | /** @throws DeployException */ | |
| 18 | public static function fromScriptOutput(string $output): self | |
| 19 | { | |
| 20 | $line = trim($output); | |
| 21 | $parts = explode(' ', $line); | |
| 22 | $state = ReleaseState::tryFrom($parts[1] ?? ''); | |
| 23 | ||
| 24 | if (\count($parts) !== 2 || $state === null) { | |
| 25 | throw DeployException::createForReason(DeployError::PrepareOutputUnexpected, output: $line); | |
| 26 | } | |
| 27 | ||
| 28 | return new self(new CommitId($parts[0]), $state); | |
| 29 | } | |
| 30 | } |