Lines
100.00%
7 / 7
Functions and Methods
100.00%
3 / 3
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| StoreSetupException | 100.00% | 7 / 7 | 100.00% | 3 / 3 | 4 | 100.00% | 1 / 1 | |||
| dsnInvalid | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| schemeUnsupported | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| unknownPeerApp | 100.00% | 5 / 5 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Store\Exception; | |
| 6 | ||
| 7 | use SensitiveParameter; | |
| 8 | use Stewart\Contracts\App\AppId; | |
| 9 | use Stewart\Contracts\Exception\StewartException; | |
| 10 | ||
| 11 | /** @extends StewartException<StoreSetupError> */ | |
| 12 | final class StoreSetupException extends StewartException | |
| 13 | { | |
| 14 | // The DSN may hold a password, so only its length reaches the message. | |
| 15 | public static function dsnInvalid(#[SensitiveParameter] string $dsn): self | |
| 16 | { | |
| 17 | return self::createForReason(StoreSetupError::DsnInvalid, length: \strlen($dsn)); | |
| 18 | } | |
| 19 | ||
| 20 | /** @param list<string> $supported */ | |
| 21 | public static function schemeUnsupported(string $scheme, array $supported): self | |
| 22 | { | |
| 23 | return self::createForReason(StoreSetupError::SchemeUnsupported, scheme: $scheme, supported: $supported); | |
| 24 | } | |
| 25 | ||
| 26 | public static function unknownPeerApp(AppId $appId, ?string $suggestion): self | |
| 27 | { | |
| 28 | return self::createForReasonWithAppendedText( | |
| 29 | StoreSetupError::UnknownPeerApp, | |
| 30 | ['appId' => $appId->value, 'suggestion' => $suggestion], | |
| 31 | $suggestion === null ? null : \sprintf('Did you mean "%s"?', $suggestion), | |
| 32 | ); | |
| 33 | } | |
| 34 | } |