Passed
Push — main ( d5c675...5a2fdf )
by MusikAnimal
06:34 queued 02:23
created

LargestPages::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 4
dl 0
loc 10
rs 10
c 1
b 0
f 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace AppBundle\Model;
5
6
use AppBundle\Repository\LargestPagesRepository;
7
8
/**
9
 * A LargestPages provides a list of the largest pages on a project.
10
 */
11
class LargestPages extends Model
12
{
13
    /** @var string */
14
    protected $includePattern;
15
16
    /** @var string */
17
    protected $excludePattern;
18
19
    /**
20
     * LargestPages constructor.
21
     * @param Project $project
22
     * @param string|int|null $namespace Namespace ID or 'all'.
23
     * @param string $includePattern Either regular expression (starts/ends with forward slash),
24
     *   or a wildcard pattern with % as the wildcard symbol.
25
     * @param string $excludePattern Either regular expression (starts/ends with forward slash),
26
     *   or a wildcard pattern with % as the wildcard symbol.
27
     */
28
    public function __construct(
29
        Project $project,
30
        $namespace = 'all',
31
        string $includePattern = '',
32
        string $excludePattern = ''
33
    ) {
34
        $this->project = $project;
35
        $this->namespace = '' == $namespace ? 0 : $namespace;
36
        $this->includePattern = $includePattern;
37
        $this->excludePattern = $excludePattern;
38
    }
39
40
    /**
41
     * Get the inclusion pattern.
42
     * @return string
43
     */
44
    public function getIncludePattern(): string
45
    {
46
        return $this->includePattern;
47
    }
48
49
    /**
50
     * Get the exclusion pattern.
51
     * @return string
52
     */
53
    public function getExcludePattern(): string
54
    {
55
        return $this->excludePattern;
56
    }
57
58
    /**
59
     * Get the largest pages on the project.
60
     * @return Page[]
61
     */
62
    public function getResults(): array
63
    {
64
        /** @var LargestPagesRepository $repo */
65
        $repo = $this->getRepository();
66
67
        return $repo->getData($this->project, $this->namespace, $this->includePattern, $this->excludePattern);
68
    }
69
}
70