1 | <?php |
||
12 | class UserAgentClient implements RobotsTxtInterface |
||
13 | { |
||
14 | /** |
||
15 | * Allow rules |
||
16 | * @var DisAllow |
||
17 | */ |
||
18 | protected $allow; |
||
19 | |||
20 | /** |
||
21 | * Disallow rules |
||
22 | * @var DisAllow |
||
23 | */ |
||
24 | protected $disallow; |
||
25 | |||
26 | /** |
||
27 | * User-agent |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $userAgent; |
||
31 | |||
32 | /** |
||
33 | * Robots.txt origin |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $origin; |
||
37 | |||
38 | /** |
||
39 | * Status code parser |
||
40 | * @var StatusCodeParser |
||
41 | */ |
||
42 | protected $statusCodeParser; |
||
43 | |||
44 | /** |
||
45 | * UserAgentClient constructor. |
||
46 | * |
||
47 | * @param DisAllow $allow |
||
48 | * @param DisAllow $disallow |
||
49 | * @param string $userAgent |
||
50 | * @param string $origin |
||
51 | * @param int $statusCode |
||
52 | */ |
||
53 | public function __construct($allow, $disallow, $userAgent, $origin, $statusCode) |
||
61 | |||
62 | /** |
||
63 | * Check if URL is allowed to crawl |
||
64 | * |
||
65 | * @param string $url |
||
66 | * @return bool |
||
67 | */ |
||
68 | public function isAllowed($url) |
||
72 | |||
73 | /** |
||
74 | * Check |
||
75 | * |
||
76 | * @param string $directive |
||
77 | * @param string $url - URL to check |
||
78 | * @return bool |
||
79 | * @throws ClientException |
||
80 | */ |
||
81 | protected function check($directive, $url) |
||
98 | |||
99 | /** |
||
100 | * Check if the URL belongs to current robots.txt |
||
101 | * |
||
102 | * @param $urls |
||
103 | * @return bool |
||
104 | */ |
||
105 | protected function isUrlApplicable($urls) |
||
119 | |||
120 | /** |
||
121 | * Check if URL is disallowed to crawl |
||
122 | * |
||
123 | * @param string $url |
||
124 | * @return bool |
||
125 | */ |
||
126 | public function isDisallowed($url) |
||
130 | |||
131 | /** |
||
132 | * Get Cache-delay |
||
133 | * |
||
134 | * @return float|int |
||
135 | */ |
||
136 | public function getCacheDelay() |
||
141 | |||
142 | /** |
||
143 | * Get Crawl-delay |
||
144 | * |
||
145 | * @return float|int |
||
146 | */ |
||
147 | public function getCrawlDelay() |
||
152 | } |
||
153 |