Conditions | 3 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
20 | 5 | public static function fromSlug(string $slug, ?string $domain = null): self |
|
21 | { |
||
22 | 5 | $suffix = $domain === null ? '' : sprintf(' for domain "%s"', $domain); |
|
23 | 5 | $e = new self(sprintf('Provided slug "%s" is already in use%s.', $slug, $suffix)); |
|
24 | |||
25 | 5 | $e->detail = $e->getMessage(); |
|
26 | 5 | $e->title = self::TITLE; |
|
27 | 5 | $e->type = self::TYPE; |
|
28 | 5 | $e->status = StatusCodeInterface::STATUS_BAD_REQUEST; |
|
29 | 5 | $e->additional = ['customSlug' => $slug]; |
|
30 | |||
31 | 5 | if ($domain !== null) { |
|
32 | 2 | $e->additional['domain'] = $domain; |
|
33 | } |
||
34 | |||
35 | 5 | return $e; |
|
36 | } |
||
38 |