LargestPages::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

68
        return $this->repository->/** @scrutinizer ignore-call */ getData(
Loading history...
69
            $this->project,
70
            $this->namespace,
71
            $this->includePattern,
72
            $this->excludePattern
73
        );
74
    }
75
}
76