| Total Complexity | 3 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | final class RequestFactory implements RequestFactoryInterface |
||
| 15 | { |
||
| 16 | public const REQUEST_JSON = 'json'; |
||
| 17 | |||
| 18 | private const DEFAULT_REQUEST_HEADERS = [ |
||
| 19 | 'HTTP_ACCEPT' => 'application/json', |
||
| 20 | 'CONTENT_TYPE' => 'application/json', |
||
| 21 | ]; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * {@inheritdoc} |
||
| 25 | */ |
||
| 26 | 1 | public function create(string $method, string $uri, array $options = []): Request |
|
| 27 | { |
||
| 28 | 1 | return Request::create( |
|
| 29 | 1 | EnvAccess::get('BASE_URI') . $uri, |
|
| 30 | 1 | $method, |
|
| 31 | 1 | $options['parameters'] ?? [], |
|
| 32 | 1 | $options['cookies'] ?? [], |
|
| 33 | 1 | $options['files'] ?? [], |
|
| 34 | 1 | array_merge(self::DEFAULT_REQUEST_HEADERS, $options['headers'] ?? []), |
|
| 35 | 1 | $this->buildRequestBody($options), |
|
| 36 | ); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param string[][] $options |
||
| 41 | */ |
||
| 42 | 1 | private function buildRequestBody(array $options): ?string |
|
| 49 | } |
||
| 50 | } |
||
| 51 |