Completed
Push — master ( 21430a...79e12b )
by Jeroen
02:36
created

ParsedSelector::getFunction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Jerodev\Diglett\Models;
4
5
use Jerodev\Diglett\CssFilters\ICssFilter;
6
7
class ParsedSelector
8
{
9
    /** @var null|string */
10
    private $selector;
11
12
    /** @var ICssFilter[] */
13
    private $functions;
14
15
    /**
16
     *  @param null|string $selector
17
     *  @param ICssFilter[] $functions
18
     */
19
    public function __construct(?string $selector = null, array $functions = [])
20
    {
21
        $this->selector = $selector;
22
        $this->functions = $functions;
23
    }
24
25
    /**
26
     *  @return null|string;
27
     */
28
    public function getSelector(): ?string
29
    {
30
        return $this->selector;
31
    }
32
33
    /**
34
     *  @return ICssFilter[]
35
     */
36
    public function getFunctions(): array
37
    {
38
        return $this->functions;
39
    }
40
41
    /**
42
     *  Return the function at a specific index
43
     *
44
     *  @param int $index
45
     *
46
     *  @return ICssFilter|null
47
     */
48
    public function getFunction(int $index = 0): ?ICssFilter
49
    {
50
        return $this->functions[$index] ?? null;
51
    }
52
53
    /**
54
     *  Get the number of functions
55
     *
56
     *  @return int
57
     */
58
    public function getFunctionCount(): int
59
    {
60
        return count($this->functions);
61
    }
62
}