Completed
Push — master ( f523e0...cc6383 )
by Vinicius
04:37 queued 03:24
created

Result::setUrl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
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
    /**
22
     * @return string
23
     */
24 5
    public function getTitle(): string
25
    {
26 5
        return $this->title;
27
    }
28
29
    /**
30
     * @param string $title
31
     * @return Result
32
     */
33 5
    public function setTitle(string $title): Result
34
    {
35 5
        $this->title = $title;
36 5
        return $this;
37
    }
38
39
    /**
40
     * @return string
41
     */
42 6
    public function getUrl(): string
43
    {
44 6
        return $this->url;
45
    }
46
47
    /**
48
     * @param string $url
49
     * @return Result
50
     * @throws InvalidUrlException
51
     */
52 7
    public function setUrl(string $url): Result
53
    {
54 7
        if (!filter_var($url, FILTER_VALIDATE_URL)) {
55 1
            throw new InvalidUrlException();
56
        }
57
58 6
        $this->url = $url;
59 6
        return $this;
60
    }
61
62
    /**
63
     * @return string
64
     */
65 5
    public function getDescription(): ?string
66
    {
67 5
        return $this->description;
68
    }
69
70
    /**
71
     * @param string $description
72
     * @return Result
73
     */
74 5
    public function setDescription(string $description): Result
75
    {
76 5
        $this->description = $description;
77 5
        return $this;
78
    }
79
}
80