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

Result::setTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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