| Conditions | 4 |
| Paths | 2 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | public function fetch(Url $url) |
||
| 8 | { |
||
| 9 | if ($url->isImage()) { |
||
| 10 | return new Resource( |
||
| 11 | $url, |
||
| 12 | '', |
||
| 13 | '', |
||
| 14 | $url, |
||
| 15 | null, |
||
| 16 | 'image' |
||
| 17 | ); |
||
| 18 | } |
||
| 19 | |||
| 20 | $browser = new \Buzz\Browser(new \Buzz\Client\Curl()); |
||
| 21 | $response = $browser->get((string) $url); |
||
| 22 | |||
| 23 | $parsedData = (new Parser())->parse($response->getContent(), $url); |
||
| 24 | |||
| 25 | return new Resource( |
||
| 26 | $url, |
||
| 27 | $parsedData->title, |
||
| 28 | $parsedData->description, |
||
| 29 | (null !== $parsedData->imageUrl) ? new Url($parsedData->imageUrl) : null, |
||
| 30 | (null !== $parsedData->videoUrl) ? new Url($parsedData->videoUrl) : null, |
||
| 31 | $parsedData->type |
||
| 32 | ); |
||
| 33 | } |
||
| 34 | } |
||
| 35 |