1 | <?php |
||
16 | abstract class Parser implements RobotsTxtInterface |
||
17 | { |
||
18 | use Toolbox; |
||
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 | /** |
||
31 | * RAW robots.txt content |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $raw; |
||
35 | |||
36 | /** |
||
37 | * Previous directive |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $previousDirective; |
||
41 | |||
42 | /** |
||
43 | * Current user-agent(s) |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $userAgentValues; |
||
47 | |||
48 | /** |
||
49 | * Clean-param class |
||
50 | * @var CleanParam |
||
51 | */ |
||
52 | protected $cleanParam; |
||
53 | |||
54 | /** |
||
55 | * Host class |
||
56 | * @var Host |
||
57 | */ |
||
58 | protected $host; |
||
59 | |||
60 | /** |
||
61 | * Sitemap class |
||
62 | * @var Sitemap |
||
63 | */ |
||
64 | protected $sitemap; |
||
65 | |||
66 | /** |
||
67 | * User-agent class |
||
68 | * @var UserAgent |
||
69 | */ |
||
70 | protected $userAgent; |
||
71 | |||
72 | /** |
||
73 | * Core constructor. |
||
74 | * |
||
75 | * @param string $content - file content |
||
76 | * @param string $encoding - character encoding |
||
77 | * @param integer|null $byteLimit - maximum of bytes to parse |
||
78 | * @throws ParserException |
||
79 | */ |
||
80 | public function __construct($content, $encoding = self::ENCODING, $byteLimit = self::BYTE_LIMIT) |
||
96 | |||
97 | /** |
||
98 | * Parse robots.txt |
||
99 | * |
||
100 | * @return void |
||
101 | */ |
||
102 | private function parseTxt() |
||
115 | |||
116 | /** |
||
117 | * Add line |
||
118 | * |
||
119 | * @param string $line |
||
120 | * @return bool |
||
121 | */ |
||
122 | public function add($line) |
||
145 | |||
146 | /** |
||
147 | * Export |
||
148 | * |
||
149 | * @return array |
||
150 | */ |
||
151 | public function export() |
||
158 | } |
||
159 |