1 | <?php |
||
15 | class UserAgentTools implements RobotsTxtInterface |
||
16 | { |
||
17 | use UriParser; |
||
18 | |||
19 | /** |
||
20 | * Rules |
||
21 | * @var SubDirectiveHandler |
||
22 | */ |
||
23 | protected $handler; |
||
24 | |||
25 | /** |
||
26 | * Base uri |
||
27 | * @var string |
||
28 | */ |
||
29 | private $base; |
||
30 | |||
31 | /** |
||
32 | * Status code |
||
33 | * @var int|null |
||
34 | */ |
||
35 | private $statusCode; |
||
36 | |||
37 | /** |
||
38 | * DisAllowClient constructor. |
||
39 | * |
||
40 | * @param string $base |
||
41 | * @param int|null $statusCode |
||
42 | * @param SubDirectiveHandler $handler |
||
43 | */ |
||
44 | public function __construct(SubDirectiveHandler $handler, $base, $statusCode) |
||
50 | |||
51 | /** |
||
52 | * UserAgentClient destructor. |
||
53 | */ |
||
54 | public function __destruct() |
||
58 | |||
59 | /** |
||
60 | * Check if URL is allowed to crawl |
||
61 | * |
||
62 | * @param string $url |
||
63 | * @return bool |
||
64 | */ |
||
65 | public function isAllowed($url) |
||
69 | |||
70 | /** |
||
71 | * Check |
||
72 | * |
||
73 | * @param string $directive |
||
74 | * @param string $url |
||
75 | * @return bool |
||
76 | * @throws ClientException |
||
77 | */ |
||
78 | private function check($directive, $url) |
||
100 | |||
101 | /** |
||
102 | * Check path |
||
103 | * |
||
104 | * @param string $directive |
||
105 | * @param string $url |
||
106 | * @return bool |
||
107 | */ |
||
108 | private function checkPath($directive, $url) |
||
127 | |||
128 | /** |
||
129 | * Check if URL is disallowed to crawl |
||
130 | * |
||
131 | * @param string $url |
||
132 | * @return bool |
||
133 | */ |
||
134 | public function isDisallowed($url) |
||
138 | |||
139 | /** |
||
140 | * Rule export |
||
141 | * |
||
142 | * @return array |
||
143 | */ |
||
144 | public function export() |
||
158 | } |
||
159 |