1 | <?php |
||
14 | class DisAllowParser implements ParserInterface, RobotsTxtInterface |
||
15 | { |
||
16 | use DirectiveParserCommons; |
||
17 | use UrlParser; |
||
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 | * @var string |
||
38 | */ |
||
39 | private $directive; |
||
40 | |||
41 | /** |
||
42 | * Base Uri |
||
43 | * @var string |
||
44 | */ |
||
45 | private $base; |
||
46 | |||
47 | /** |
||
48 | * Rule array |
||
49 | * @var array |
||
50 | */ |
||
51 | private $array = []; |
||
52 | |||
53 | /** |
||
54 | * Sub-directive Clean-param |
||
55 | * @var CleanParamParser |
||
56 | */ |
||
57 | private $cleanParam; |
||
58 | |||
59 | /** |
||
60 | * Sub-directive Host |
||
61 | * @var HostParser |
||
62 | */ |
||
63 | private $host; |
||
64 | |||
65 | /** |
||
66 | * DisAllow constructor |
||
67 | * |
||
68 | * @param string $base |
||
69 | * @param string $directive |
||
70 | */ |
||
71 | public function __construct($base, $directive) |
||
78 | |||
79 | /** |
||
80 | * Add |
||
81 | * |
||
82 | * @param string $line |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function add($line) |
||
96 | |||
97 | /** |
||
98 | * Add plain path to allow/disallow |
||
99 | * |
||
100 | * @param string $rule |
||
101 | * @return bool |
||
102 | */ |
||
103 | private function addPath($rule) |
||
111 | |||
112 | /** |
||
113 | * Rule array |
||
114 | * |
||
115 | * @return array |
||
116 | */ |
||
117 | public function getRules() |
||
126 | |||
127 | /** |
||
128 | * Render |
||
129 | * |
||
130 | * @return string[] |
||
131 | */ |
||
132 | public function render() |
||
151 | |||
152 | /** |
||
153 | * Client |
||
154 | * |
||
155 | * @return DisAllowClient |
||
156 | */ |
||
157 | public function client() |
||
161 | } |
||
162 |