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( |
|
|
|
|
69
|
|
|
$this->project, |
70
|
|
|
$this->namespace, |
71
|
|
|
$this->includePattern, |
72
|
|
|
$this->excludePattern |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|