1 | <?php |
||
21 | class AllowParser implements ParserInterface, RobotsTxtInterface |
||
22 | { |
||
23 | use DirectiveParserTrait; |
||
24 | |||
25 | /** |
||
26 | * Sub directives white list |
||
27 | */ |
||
28 | const SUB_DIRECTIVES = [ |
||
29 | self::DIRECTIVE_CLEAN_PARAM, |
||
30 | self::DIRECTIVE_HOST, |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * Directive |
||
35 | * @var string |
||
36 | */ |
||
37 | private $directive; |
||
38 | |||
39 | /** |
||
40 | * Path |
||
41 | * @var array |
||
42 | */ |
||
43 | private $path = []; |
||
44 | |||
45 | /** |
||
46 | * Sub-directive Clean-param |
||
47 | * @var InlineCleanParamParser |
||
48 | */ |
||
49 | private $cleanParam; |
||
50 | |||
51 | /** |
||
52 | * Sub-directive Host |
||
53 | * @var InlineHostParser |
||
54 | */ |
||
55 | private $host; |
||
56 | |||
57 | /** |
||
58 | * Optimized for performance |
||
59 | * @var bool |
||
60 | */ |
||
61 | private $optimized = false; |
||
62 | |||
63 | /** |
||
64 | * Client cache |
||
65 | * @var AllowClient |
||
66 | */ |
||
67 | private $client; |
||
68 | |||
69 | /** |
||
70 | * AllowParser constructor |
||
71 | * |
||
72 | * @param string $base |
||
73 | * @param string $effective |
||
74 | * @param string $directive |
||
75 | */ |
||
76 | public function __construct($base, $effective, $directive) |
||
82 | |||
83 | /** |
||
84 | * Add |
||
85 | * |
||
86 | * @param string $line |
||
87 | * @return bool |
||
88 | */ |
||
89 | public function add($line) |
||
100 | |||
101 | /** |
||
102 | * Add plain path to allow/disallow |
||
103 | * |
||
104 | * @param string $path |
||
105 | * @return bool |
||
106 | */ |
||
107 | private function addPath($path) |
||
119 | |||
120 | /** |
||
121 | * Render |
||
122 | * |
||
123 | * @param RenderHandler $handler |
||
124 | * @return bool |
||
125 | */ |
||
126 | public function render(RenderHandler $handler) |
||
141 | |||
142 | /** |
||
143 | * Remove overlapping paths |
||
144 | * |
||
145 | * @return bool |
||
146 | */ |
||
147 | private function removeOverlapping() |
||
163 | |||
164 | /** |
||
165 | * Client |
||
166 | * |
||
167 | * @return AllowClient |
||
168 | */ |
||
169 | public function client() |
||
178 | } |
||
179 |