1 | <?php |
||
15 | class UserAgentTools implements RobotsTxtInterface |
||
16 | { |
||
17 | use UrlParser; |
||
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) |
||
94 | |||
95 | /** |
||
96 | * Check path |
||
97 | * |
||
98 | * @param string $directive |
||
99 | * @param string $url |
||
100 | * @return bool |
||
101 | */ |
||
102 | private function checkPath($directive, $url) |
||
117 | |||
118 | /** |
||
119 | * Check if URL is disallowed to crawl |
||
120 | * |
||
121 | * @param string $url |
||
122 | * @return bool |
||
123 | */ |
||
124 | public function isDisallowed($url) |
||
128 | |||
129 | /** |
||
130 | * Rule export |
||
131 | * |
||
132 | * @return array |
||
133 | */ |
||
134 | public function export() |
||
147 | } |
||
148 |