1 | <?php |
||
13 | class AllowParser implements ParserInterface, RobotsTxtInterface |
||
14 | { |
||
15 | use DirectiveParserCommons; |
||
16 | |||
17 | /** |
||
18 | * Sub directives white list |
||
19 | */ |
||
20 | const SUB_DIRECTIVES = [ |
||
21 | self::DIRECTIVE_CLEAN_PARAM, |
||
22 | self::DIRECTIVE_HOST, |
||
23 | ]; |
||
24 | |||
25 | /** |
||
26 | * Directive |
||
27 | * @var string |
||
28 | */ |
||
29 | private $directive; |
||
30 | |||
31 | /** |
||
32 | * Path |
||
33 | * @var array |
||
34 | */ |
||
35 | private $path = []; |
||
36 | |||
37 | /** |
||
38 | * Sub-directive Clean-param |
||
39 | * @var CleanParamParser |
||
40 | */ |
||
41 | private $cleanParam; |
||
42 | |||
43 | /** |
||
44 | * Sub-directive Host |
||
45 | * @var HostParser |
||
46 | */ |
||
47 | private $host; |
||
48 | |||
49 | /** |
||
50 | * AllowParser constructor |
||
51 | * |
||
52 | * @param string $base |
||
53 | * @param string $effective |
||
54 | * @param string $directive |
||
55 | */ |
||
56 | public function __construct($base, $effective, $directive) |
||
62 | |||
63 | /** |
||
64 | * Add |
||
65 | * |
||
66 | * @param string $line |
||
67 | * @return bool |
||
68 | */ |
||
69 | public function add($line) |
||
80 | |||
81 | /** |
||
82 | * Add plain path to allow/disallow |
||
83 | * |
||
84 | * @param string $path |
||
85 | * @return bool |
||
86 | */ |
||
87 | private function addPath($path) |
||
104 | |||
105 | /** |
||
106 | * Check if path is valid |
||
107 | * |
||
108 | * @param string $path |
||
109 | * @return bool |
||
110 | */ |
||
111 | private function isPath($path) |
||
124 | |||
125 | /** |
||
126 | * Remove overlapping paths |
||
127 | * |
||
128 | * @return bool |
||
129 | */ |
||
130 | private function removeOverlapping() |
||
145 | |||
146 | /** |
||
147 | * Render |
||
148 | * |
||
149 | * @return string[] |
||
150 | */ |
||
151 | public function render() |
||
168 | |||
169 | /** |
||
170 | * Client |
||
171 | * |
||
172 | * @return AllowClient |
||
173 | */ |
||
174 | public function client() |
||
178 | } |
||
179 |