1 | <?php |
||
14 | class DisAllow implements DirectiveInterface, RobotsTxtInterface |
||
15 | { |
||
16 | use Toolbox; |
||
17 | use UrlTools; |
||
18 | |||
19 | /** |
||
20 | * Directive alternatives |
||
21 | */ |
||
22 | const DIRECTIVE = [ |
||
23 | self::DIRECTIVE_ALLOW, |
||
24 | self::DIRECTIVE_DISALLOW, |
||
25 | ]; |
||
26 | |||
27 | /** |
||
28 | * Sub directives white list |
||
29 | */ |
||
30 | const SUB_DIRECTIVES = [ |
||
31 | self::DIRECTIVE_CLEAN_PARAM, |
||
32 | self::DIRECTIVE_HOST, |
||
33 | ]; |
||
34 | |||
35 | /** |
||
36 | * Directive |
||
37 | */ |
||
38 | protected $directive; |
||
39 | |||
40 | /** |
||
41 | * Rule array |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $array = []; |
||
45 | |||
46 | /** |
||
47 | * Sub-directive Clean-param |
||
48 | * @var CleanParam |
||
49 | */ |
||
50 | protected $cleanParam; |
||
51 | |||
52 | /** |
||
53 | * Sub-directive Host |
||
54 | * @var Host |
||
55 | */ |
||
56 | protected $host; |
||
57 | |||
58 | /** |
||
59 | * DisAllow constructor |
||
60 | * |
||
61 | * @param string $directive |
||
62 | * @throws Exceptions\ParserException |
||
63 | */ |
||
64 | public function __construct($directive) |
||
70 | |||
71 | /** |
||
72 | * Add |
||
73 | * |
||
74 | * @param string $line |
||
75 | * @return bool |
||
76 | */ |
||
77 | public function add($line) |
||
88 | |||
89 | /** |
||
90 | * Add plain path to allow/disallow |
||
91 | * |
||
92 | * @param string $rule |
||
93 | * @return bool |
||
94 | */ |
||
95 | protected function addPath($rule) |
||
104 | |||
105 | /** |
||
106 | * Check |
||
107 | * |
||
108 | * @param string $url |
||
109 | * @return bool |
||
110 | */ |
||
111 | public function check($url) |
||
120 | |||
121 | /** |
||
122 | * Get path |
||
123 | * |
||
124 | * @param string $url |
||
125 | * @return string |
||
126 | * @throws Exceptions\ClientException |
||
127 | */ |
||
128 | protected function getPath($url) |
||
140 | |||
141 | /** |
||
142 | * Export |
||
143 | * |
||
144 | * @return array |
||
145 | */ |
||
146 | public function export() |
||
153 | } |
||
154 |