1
|
|
|
<?php |
2
|
|
|
namespace vipnytt\RobotsTxtParser\Handler\Directives; |
3
|
|
|
|
4
|
|
|
use vipnytt\RobotsTxtParser\Parser\Directives\AllowParser; |
5
|
|
|
use vipnytt\RobotsTxtParser\Parser\Directives\CommentParser; |
6
|
|
|
use vipnytt\RobotsTxtParser\Parser\Directives\DelayParser; |
7
|
|
|
use vipnytt\RobotsTxtParser\Parser\Directives\RequestRateParser; |
8
|
|
|
use vipnytt\RobotsTxtParser\Parser\Directives\RobotVersionParser; |
9
|
|
|
use vipnytt\RobotsTxtParser\Parser\Directives\VisitTimeParser; |
10
|
|
|
use vipnytt\RobotsTxtParser\RobotsTxtInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class SubDirectiveHandler |
14
|
|
|
* |
15
|
|
|
* @package vipnytt\RobotsTxtParser\Parser\Directives |
16
|
|
|
*/ |
17
|
|
|
class SubDirectiveHandler implements RobotsTxtInterface |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Allow |
21
|
|
|
* @var AllowParser |
22
|
|
|
*/ |
23
|
|
|
private $allow; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Cache-delay |
27
|
|
|
* @var DelayParser |
28
|
|
|
*/ |
29
|
|
|
private $cacheDelay; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Comment |
33
|
|
|
* @var CommentParser |
34
|
|
|
*/ |
35
|
|
|
private $comment; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Crawl-delay |
39
|
|
|
* @var DelayParser |
40
|
|
|
*/ |
41
|
|
|
private $crawlDelay; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Disallow |
45
|
|
|
* @var AllowParser |
46
|
|
|
*/ |
47
|
|
|
private $disallow; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* NoIndex |
51
|
|
|
* @var AllowParser |
52
|
|
|
*/ |
53
|
|
|
private $noIndex; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Request-rate |
57
|
|
|
* @var RequestRateParser |
58
|
|
|
*/ |
59
|
|
|
private $requestRate; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Robot-version |
63
|
|
|
* @var RobotVersionParser |
64
|
|
|
*/ |
65
|
|
|
private $robotVersion; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Visit-time |
69
|
|
|
* @var VisitTimeParser |
70
|
|
|
*/ |
71
|
|
|
private $visitTime; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* SubDirectiveHandler constructor. |
75
|
|
|
* |
76
|
|
|
* @param string $base |
77
|
|
|
* @param string $effective |
78
|
|
|
* @param string $userAgent |
79
|
|
|
*/ |
80
|
|
|
public function __construct($base, $effective, $userAgent) |
81
|
|
|
{ |
82
|
|
|
$this->allow = new AllowParser($base, $effective, self::DIRECTIVE_ALLOW); |
83
|
|
|
$this->cacheDelay = new DelayParser($base, self::DIRECTIVE_CACHE_DELAY); |
84
|
|
|
$this->comment = new CommentParser($base, $userAgent); |
85
|
|
|
$this->crawlDelay = new DelayParser($base, self::DIRECTIVE_CRAWL_DELAY); |
86
|
|
|
$this->disallow = new AllowParser($base, $effective, self::DIRECTIVE_DISALLOW); |
87
|
|
|
$this->noIndex = new AllowParser($base, $effective, self::DIRECTIVE_NO_INDEX); |
88
|
|
|
$this->requestRate = new RequestRateParser($base); |
89
|
|
|
$this->robotVersion = new RobotVersionParser(); |
90
|
|
|
$this->visitTime = new VisitTimeParser(); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Allow |
95
|
|
|
* |
96
|
|
|
* @return AllowParser |
97
|
|
|
*/ |
98
|
|
|
public function allow() |
99
|
|
|
{ |
100
|
|
|
return $this->allow; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Cache-delay |
105
|
|
|
* |
106
|
|
|
* @return DelayParser |
107
|
|
|
*/ |
108
|
|
|
public function cacheDelay() |
109
|
|
|
{ |
110
|
|
|
return $this->cacheDelay; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Comment |
115
|
|
|
* |
116
|
|
|
* @return CommentParser |
117
|
|
|
*/ |
118
|
|
|
public function comment() |
119
|
|
|
{ |
120
|
|
|
return $this->comment; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Crawl-delay |
125
|
|
|
* |
126
|
|
|
* @return DelayParser |
127
|
|
|
*/ |
128
|
|
|
public function crawlDelay() |
129
|
|
|
{ |
130
|
|
|
return $this->crawlDelay; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Disallow |
135
|
|
|
* |
136
|
|
|
* @return AllowParser |
137
|
|
|
*/ |
138
|
|
|
public function disallow() |
139
|
|
|
{ |
140
|
|
|
return $this->disallow; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* NoIndex |
145
|
|
|
* |
146
|
|
|
* @return AllowParser |
147
|
|
|
*/ |
148
|
|
|
public function noIndex() |
149
|
|
|
{ |
150
|
|
|
return $this->noIndex; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Request-rate |
155
|
|
|
* |
156
|
|
|
* @return RequestRateParser |
157
|
|
|
*/ |
158
|
|
|
public function requestRate() |
159
|
|
|
{ |
160
|
|
|
return $this->requestRate; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Robot-version |
165
|
|
|
* |
166
|
|
|
* @return RobotVersionParser |
167
|
|
|
*/ |
168
|
|
|
public function robotVersion() |
169
|
|
|
{ |
170
|
|
|
return $this->robotVersion; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Visit-time |
175
|
|
|
* |
176
|
|
|
* @return VisitTimeParser |
177
|
|
|
*/ |
178
|
|
|
public function visitTime() |
179
|
|
|
{ |
180
|
|
|
return $this->visitTime; |
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
|