Total Complexity | 4 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Coverage | 66.67% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | class Psr7Request extends Source |
||
16 | { |
||
17 | use GuzzleAware; |
||
18 | |||
19 | /** |
||
20 | * The endpoint response. |
||
21 | * |
||
22 | * @var ResponseInterface|null |
||
23 | */ |
||
24 | protected ?ResponseInterface $response; |
||
25 | |||
26 | /** |
||
27 | * Retrieve the JSON fragments |
||
28 | * |
||
29 | * @return Traversable<int, string> |
||
30 | * @throws \Cerbero\JsonParser\Exceptions\GuzzleRequiredException |
||
31 | */ |
||
32 | 1 | public function getIterator(): Traversable |
|
33 | { |
||
34 | 1 | return new Psr7Message($this->response(), $this->config); |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * Retrieve the response of the PSR-7 request |
||
39 | * |
||
40 | * @return ResponseInterface |
||
41 | * @throws \Cerbero\JsonParser\Exceptions\GuzzleRequiredException |
||
42 | */ |
||
43 | 1 | protected function response(): ResponseInterface |
|
44 | { |
||
45 | 1 | $this->requireGuzzle(); |
|
46 | |||
47 | return $this->response ??= $this->sendRequest($this->source); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Determine whether the JSON source can be handled |
||
52 | * |
||
53 | * @return bool |
||
54 | */ |
||
55 | 1 | public function matches(): bool |
|
58 | } |
||
59 | |||
60 | /** |
||
61 | * Retrieve the calculated size of the JSON source |
||
62 | * |
||
63 | * @return int|null |
||
64 | */ |
||
65 | protected function calculateSize(): ?int |
||
68 | } |
||
69 | } |
||
70 |