Conditions | 4 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function fetch(array $parameters = []): ?Embed |
||
19 | { |
||
20 | $data = array_merge($parameters ?: $this->parameters, ['url' => $this->url]); |
||
21 | $query = http_build_query($data); |
||
22 | $response = file_get_contents((string) $this->provider . '?' . $query); |
||
23 | |||
24 | if (!$response) { |
||
25 | return null; |
||
26 | } |
||
27 | |||
28 | $data = json_decode($response, true); |
||
29 | |||
30 | if (!$data) { |
||
31 | throw new ExtractorException('Invalid JSON response from OEmbed provider. Url: ' . $this->url); |
||
32 | } |
||
33 | |||
34 | $embed = new Embed(Embed::TYPE_OEMBED, $this->url, $data); |
||
35 | |||
36 | return $embed; |
||
37 | } |
||
39 |