Completed
Push — master ( a780c1...708060 )
by Vinicius
04:57
created

Result   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 50
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 4 1
A setUrl() 0 9 2
A getDescription() 0 4 1
A setDescription() 0 6 1
A getTitle() 0 4 1
A setTitle() 0 5 1
1
<?php
2
namespace CViniciusSDias\GoogleCrawler;
3
4
use CViniciusSDias\GoogleCrawler\Exception\InvalidUrlException;
5
6
/**
7
 * Class that represents a Google Result
8
 *
9
 * @package CViniciussDias\GoogleCrawler
10
 * @author Vinicius Dias
11
 */
12
class Result
13
{
14
    /** @var string $title */
15
    private $title;
16
    /** @var string $url */
17
    private $url;
18
    /** @var string $description */
19
    private $description;
20
21 10
    public function getTitle(): string
22
    {
23 10
        return $this->title;
24
    }
25
26 10
    public function setTitle(string $title): Result
27
    {
28 10
        $this->title = $title;
29 10
        return $this;
30
    }
31
32 11
    public function getUrl(): string
33
    {
34 11
        return $this->url;
35
    }
36
37
    /**
38
     * @throws InvalidUrlException
39
     */
40 12
    public function setUrl(string $url): Result
41
    {
42 12
        if (!filter_var($url, FILTER_VALIDATE_URL)) {
43 1
            throw new InvalidUrlException();
44
        }
45
46 11
        $this->url = $url;
47 11
        return $this;
48
    }
49
50 11
    public function getDescription(): ?string
51
    {
52 11
        return $this->description;
53
    }
54
55 11
    public function setDescription(string $description): Result
56
    {
57 11
        $description = trim(str_replace("\n", ' ', $description));
58 11
        $this->description = $description;
59 11
        return $this;
60
    }
61
}
62