Result   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 72.21%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getTitle() 0 4 1
A setTitle() 0 5 1
A getUrl() 0 4 1
A setUrl() 0 9 2
A getDescription() 0 4 1
A setDescription() 0 6 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
    public function getTitle(): string
22
    {
23
        return $this->title;
24
    }
25
26
    public function setTitle(string $title): Result
27
    {
28
        $this->title = $title;
29
        return $this;
30
    }
31
32 1
    public function getUrl(): string
33
    {
34 1
        return $this->url;
35
    }
36
37
    /**
38
     * @throws InvalidUrlException
39
     */
40 2
    public function setUrl(string $url): Result
41
    {
42 2
        if (!filter_var($url, FILTER_VALIDATE_URL)) {
43 1
            throw new InvalidUrlException();
44
        }
45
46 1
        $this->url = $url;
47 1
        return $this;
48
    }
49
50 1
    public function getDescription(): ?string
51
    {
52 1
        return $this->description;
53
    }
54
55 1
    public function setDescription(string $description): Result
56
    {
57 1
        $description = trim(str_replace("\n", ' ', $description));
58 1
        $this->description = $description;
59 1
        return $this;
60
    }
61
}
62