Passed
Push — master ( 382b98...cf0bb6 )
by Gilles
08:40 queued 01:24
created

ParsedSelectorCollectionDTO::makeCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PHPHtmlParser\DTO\Selector;
6
7
final class ParsedSelectorCollectionDTO
8
{
9
    /**
10
     * @var ParsedSelectorDTO[]
11
     */
12
    private $parsedSelectorDTO = [];
13
14
    /**
15
     * @param ParsedSelectorDTO[] $parsedSelectorDTOs
16
     */
17 345
    private function __construct(array $parsedSelectorDTOs)
18
    {
19 345
        foreach ($parsedSelectorDTOs as $parsedSelectorDTO) {
20 345
            if ($parsedSelectorDTO instanceof ParsedSelectorDTO) {
21 345
                $this->parsedSelectorDTO[] = $parsedSelectorDTO;
22
            }
23
        }
24 345
    }
25
26
    /**
27
     * @param ParsedSelectorDTO[] $parsedSelectorDTOs
28
     */
29 345
    public static function makeCollection(array $parsedSelectorDTOs): ParsedSelectorCollectionDTO
30
    {
31 345
        return new ParsedSelectorCollectionDTO($parsedSelectorDTOs);
32
    }
33
34
    /**
35
     * @return ParsedSelectorDTO[]
36
     */
37 345
    public function getParsedSelectorDTO(): array
38
    {
39 345
        return $this->parsedSelectorDTO;
40
    }
41
}
42