Fetcher   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fetch() 0 27 4
1
<?php
2
3
namespace Fetcher;
4
5
class Fetcher
6
{
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