1 | <?php |
||
16 | class RobotsTxtParser implements RobotsTxtInterface |
||
17 | { |
||
18 | use DirectiveParserCommons; |
||
19 | |||
20 | /** |
||
21 | * Directive white list |
||
22 | */ |
||
23 | const TOP_LEVEL_DIRECTIVES = [ |
||
24 | self::DIRECTIVE_CLEAN_PARAM, |
||
25 | self::DIRECTIVE_HOST, |
||
26 | self::DIRECTIVE_SITEMAP, |
||
27 | self::DIRECTIVE_USER_AGENT, |
||
28 | ]; |
||
29 | /** |
||
30 | * Current user-agent(s) |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $userAgentValues; |
||
34 | /** |
||
35 | * Clean-param class |
||
36 | * @var CleanParamParser |
||
37 | */ |
||
38 | protected $cleanParam; |
||
39 | /** |
||
40 | * Host class |
||
41 | * @var HostParser |
||
42 | */ |
||
43 | protected $host; |
||
44 | /** |
||
45 | * Sitemap class |
||
46 | * @var SitemapParser |
||
47 | */ |
||
48 | protected $sitemap; |
||
49 | /** |
||
50 | * User-agent class |
||
51 | * @var UserAgentParser |
||
52 | */ |
||
53 | protected $userAgent; |
||
54 | /** |
||
55 | * Previous directive |
||
56 | * @var string |
||
57 | */ |
||
58 | private $previousDirective; |
||
59 | |||
60 | /** |
||
61 | * Core constructor. |
||
62 | * |
||
63 | * @param string $content - file content |
||
64 | */ |
||
65 | public function __construct($content) |
||
74 | |||
75 | /** |
||
76 | * Client robots.txt |
||
77 | * |
||
78 | * @param string $txt |
||
79 | * @return void |
||
80 | */ |
||
81 | private function parseTxt($txt) |
||
94 | |||
95 | /** |
||
96 | * Add line |
||
97 | * |
||
98 | * @param string $line |
||
99 | * @return bool |
||
100 | */ |
||
101 | public function add($line) |
||
124 | |||
125 | /** |
||
126 | * Render |
||
127 | * |
||
128 | * @param string $lineSeparator |
||
129 | * @return string |
||
130 | */ |
||
131 | public function render($lineSeparator = "\n") |
||
140 | |||
141 | /** |
||
142 | * Export rules |
||
143 | * |
||
144 | * @return array |
||
145 | */ |
||
146 | public function export() |
||
155 | } |
||
156 |