| Conditions | 4 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 56 | 12 | public function getUrlData(string $url): IframelyDTO |
|
| 57 | { |
||
| 58 | 12 | if ($this->cache && $this->cache->has(CacheInterface::KEY_PREFIX.md5($url))) { |
|
| 59 | 4 | return $this->cache->get(CacheInterface::KEY_PREFIX.md5($url)); |
|
| 60 | } |
||
| 61 | |||
| 62 | 8 | $response = $this->client->request( |
|
| 63 | 8 | 'GET', |
|
| 64 | 8 | IframelyClientInterface::API_BASE_URI, |
|
| 65 | 8 | ['query' => ['api_key' => $this->apiKey, 'url' => $url, 'html' => 1]] |
|
| 66 | ); |
||
| 67 | |||
| 68 | 8 | $dto = new IframelyDTO(json_decode($response->getBody()->getContents(), true)); |
|
| 69 | |||
| 70 | 8 | if ($this->cache) { |
|
| 71 | 4 | $this->cache->save(CacheInterface::KEY_PREFIX.md5($url), $dto, CacheInterface::LIFETIME_DAY); |
|
| 72 | } |
||
| 73 | |||
| 74 | 8 | return $dto; |
|
| 75 | } |
||
| 76 | } |
||
| 77 |