Total Complexity | 6 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | final class ShortUrlIdentifier |
||
11 | { |
||
12 | private string $shortCode; |
||
13 | private ?string $domain; |
||
14 | |||
15 | 47 | public function __construct(string $shortCode, ?string $domain = null) |
|
16 | { |
||
17 | 47 | $this->shortCode = $shortCode; |
|
18 | 47 | $this->domain = $domain; |
|
19 | } |
||
20 | |||
21 | 7 | public static function fromApiRequest(ServerRequestInterface $request): self |
|
22 | { |
||
23 | 7 | $shortCode = $request->getAttribute('shortCode', ''); |
|
24 | 7 | $domain = $request->getQueryParams()['domain'] ?? null; |
|
25 | |||
26 | 7 | return new self($shortCode, $domain); |
|
27 | } |
||
28 | |||
29 | 11 | public static function fromRedirectRequest(ServerRequestInterface $request): self |
|
30 | { |
||
31 | 11 | $shortCode = $request->getAttribute('shortCode', ''); |
|
32 | 11 | $domain = $request->getUri()->getAuthority(); |
|
33 | |||
34 | 11 | return new self($shortCode, $domain); |
|
35 | } |
||
36 | |||
37 | 12 | public static function fromCli(InputInterface $input): self |
|
43 | } |
||
44 | |||
45 | 16 | public function shortCode(): string |
|
46 | { |
||
48 | } |
||
49 | |||
50 | 13 | public function domain(): ?string |
|
55 |