| Total Complexity | 4 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | final class DataSourceName |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @param non-empty-string $dsn |
||
|
|
|||
| 24 | * @param non-empty-string $name |
||
| 25 | * |
||
| 26 | * @return non-empty-string |
||
| 27 | */ |
||
| 28 | public static function normalize(string $dsn, string $name): string |
||
| 29 | { |
||
| 30 | if (!\str_starts_with($dsn, "$name:")) { |
||
| 31 | $dsn = "$name:$dsn"; |
||
| 32 | } |
||
| 33 | |||
| 34 | return $dsn; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param non-empty-string $haystack |
||
| 39 | * @param array<non-empty-string>|non-empty-string $needle |
||
| 40 | * |
||
| 41 | * @return non-empty-string|null |
||
| 42 | */ |
||
| 43 | public static function read(string $haystack, array|string $needle): ?string |
||
| 53 | } |
||
| 54 | } |
||
| 55 |