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