1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ReliqArts\Scavenger\Model; |
6
|
|
|
|
7
|
|
|
class Target |
8
|
|
|
{ |
9
|
|
|
private const INITIAL_CURSOR = 0; |
10
|
|
|
|
11
|
|
|
private string $name; |
12
|
|
|
private bool $example; |
13
|
|
|
private bool $searchEngineRequestPages; |
14
|
|
|
private string $model; |
15
|
|
|
private string $source; |
16
|
|
|
private array $search; |
17
|
|
|
private int $pages; |
18
|
|
|
private array $pager; |
19
|
|
|
private array $markup; |
20
|
|
|
private array $dissect; |
21
|
|
|
private array $preprocess; |
22
|
|
|
private array $remap; |
23
|
|
|
private int $cursor; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string[] |
27
|
|
|
*/ |
28
|
|
|
private array $badWords; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Definition constructor. |
32
|
|
|
* |
33
|
|
|
* @param string[] $badWords |
34
|
|
|
*/ |
35
|
|
|
public function __construct( |
36
|
|
|
string $name, |
37
|
|
|
string $model, |
38
|
|
|
string $source, |
39
|
|
|
array $markup, |
40
|
|
|
array $pager = [], |
41
|
|
|
int $pages = 0, |
42
|
|
|
array $dissect = [], |
43
|
|
|
array $preprocess = [], |
44
|
|
|
array $remap = [], |
45
|
|
|
array $badWords = [], |
46
|
|
|
array $search = [], |
47
|
|
|
bool $searchEngineRequestPages = false, |
48
|
|
|
bool $example = false |
49
|
|
|
) { |
50
|
|
|
$this->name = $name; |
51
|
|
|
$this->example = $example; |
52
|
|
|
$this->searchEngineRequestPages = $searchEngineRequestPages; |
53
|
|
|
$this->model = $model; |
54
|
|
|
$this->source = $source; |
55
|
|
|
$this->search = $search; |
56
|
|
|
$this->pages = $pages; |
57
|
|
|
$this->pager = $pager; |
58
|
|
|
$this->markup = $markup; |
59
|
|
|
$this->dissect = $dissect; |
60
|
|
|
$this->preprocess = $preprocess; |
61
|
|
|
$this->remap = $remap; |
62
|
|
|
$this->badWords = $badWords; |
63
|
|
|
$this->cursor = self::INITIAL_CURSOR; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getName(): string |
67
|
|
|
{ |
68
|
|
|
return $this->name; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function isExample(): bool |
72
|
|
|
{ |
73
|
|
|
return $this->example; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function isSearchEngineRequestPages(): bool |
77
|
|
|
{ |
78
|
|
|
return $this->searchEngineRequestPages; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function getModel(): string |
82
|
|
|
{ |
83
|
|
|
return $this->model; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function getSource(): string |
87
|
|
|
{ |
88
|
|
|
return $this->source; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function getSearch(): array |
92
|
|
|
{ |
93
|
|
|
return $this->search; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function hasSearch(): bool |
97
|
|
|
{ |
98
|
|
|
return !empty($this->search); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function getPages(): int |
102
|
|
|
{ |
103
|
|
|
return $this->pages; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function hasPages(): bool |
107
|
|
|
{ |
108
|
|
|
return !empty($this->pages); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
public function getPager(): array |
112
|
|
|
{ |
113
|
|
|
return $this->pager; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
public function hasPager(): bool |
117
|
|
|
{ |
118
|
|
|
return !empty($this->pager); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function getMarkup(): array |
122
|
|
|
{ |
123
|
|
|
return $this->markup; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function getDissect(): array |
127
|
|
|
{ |
128
|
|
|
return $this->dissect; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public function hasDissect(): bool |
132
|
|
|
{ |
133
|
|
|
return !empty($this->dissect); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function getPreprocess(): array |
137
|
|
|
{ |
138
|
|
|
return $this->preprocess; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
public function hasPreprocess(): bool |
142
|
|
|
{ |
143
|
|
|
return !empty($this->preprocess); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function getRemap(): array |
147
|
|
|
{ |
148
|
|
|
return $this->remap; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function hasRemap(): bool |
152
|
|
|
{ |
153
|
|
|
return !empty($this->remap); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return string[] |
158
|
|
|
*/ |
159
|
|
|
public function getBadWords(): array |
160
|
|
|
{ |
161
|
|
|
return $this->badWords; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
public function hasBadWords(): bool |
165
|
|
|
{ |
166
|
|
|
return !empty($this->badWords); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
public function getCursor(): int |
170
|
|
|
{ |
171
|
|
|
return $this->cursor; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
public function setCursor(int $cursor): void |
175
|
|
|
{ |
176
|
|
|
$this->cursor = $cursor; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Increment cursor by 1. |
181
|
|
|
*/ |
182
|
|
|
public function incrementCursor(): void |
183
|
|
|
{ |
184
|
|
|
++$this->cursor; |
185
|
|
|
} |
186
|
|
|
} |
187
|
|
|
|