| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | 7 | protected function buildShortUrlData(Request $request): CreateShortUrlData |
|
| 23 | 7 | { |
|
| 24 | 1 | $payload = (array) $request->getParsedBody(); |
|
| 25 | 1 | if (! isset($payload['longUrl'])) { |
|
| 26 | throw ValidationException::fromArray([ |
||
| 27 | 'longUrl' => 'A URL was not provided', |
||
| 28 | ]); |
||
| 29 | 6 | } |
|
| 30 | 3 | ||
| 31 | $payload[ShortUrlMetaInputFilter::API_KEY] = AuthenticationMiddleware::apiKeyFromRequest($request); |
||
| 32 | $meta = ShortUrlMeta::fromRawData($payload); |
||
| 33 | |||
| 34 | return new CreateShortUrlData($payload['longUrl'], (array) ($payload['tags'] ?? []), $meta); |
||
| 35 | } |
||
| 37 |