Total Complexity | 3 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Coverage | 50% |
Changes | 1 | ||
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 | $this->requireGuzzle(); |
|
35 | |||
36 | $this->response = $this->sendRequest($this->source); |
||
37 | |||
38 | return new Psr7Message($this->response, $this->config); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Determine whether the JSON source can be handled |
||
43 | * |
||
44 | * @return bool |
||
45 | */ |
||
46 | 1 | public function matches(): bool |
|
47 | { |
||
48 | 1 | return $this->source instanceof RequestInterface; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Retrieve the calculated size of the JSON source |
||
53 | * |
||
54 | * @return int|null |
||
55 | */ |
||
56 | protected function calculateSize(): ?int |
||
59 | } |
||
60 | } |
||
61 |