1 | <?php |
||
12 | class UserAgent implements DirectiveInterface, RobotsTxtInterface |
||
13 | { |
||
14 | use Toolbox; |
||
15 | |||
16 | /** |
||
17 | * Sub directives white list |
||
18 | */ |
||
19 | const SUB_DIRECTIVES = [ |
||
20 | self::DIRECTIVE_ALLOW, |
||
21 | self::DIRECTIVE_CACHE_DELAY, |
||
22 | self::DIRECTIVE_CRAWL_DELAY, |
||
23 | self::DIRECTIVE_DISALLOW, |
||
24 | ]; |
||
25 | |||
26 | /** |
||
27 | * Directive |
||
28 | */ |
||
29 | const DIRECTIVE = self::DIRECTIVE_USER_AGENT; |
||
30 | |||
31 | /** |
||
32 | * All User-agents declared |
||
33 | * @var array |
||
34 | */ |
||
35 | public $userAgents = []; |
||
36 | |||
37 | /** |
||
38 | * Sub-directive Allow |
||
39 | * @var array |
||
40 | */ |
||
41 | public $allow = []; |
||
42 | |||
43 | /** |
||
44 | * Sub-directive Cache-delay |
||
45 | * @var array |
||
46 | */ |
||
47 | public $cacheDelay = []; |
||
48 | |||
49 | /** |
||
50 | * Sub-directive Crawl-delay |
||
51 | * @var array |
||
52 | */ |
||
53 | public $crawlDelay = []; |
||
54 | |||
55 | /** |
||
56 | * Sub-directive Disallow |
||
57 | * @var array |
||
58 | */ |
||
59 | public $disallow = []; |
||
60 | |||
61 | /** |
||
62 | * Current User-agent(s) |
||
63 | * @var array |
||
64 | */ |
||
65 | protected $userAgent = []; |
||
66 | |||
67 | /** |
||
68 | * UserAgent constructor. |
||
69 | */ |
||
70 | public function __construct() |
||
74 | |||
75 | /** |
||
76 | * Set new User-agent |
||
77 | * |
||
78 | * @param array $array |
||
79 | * @return bool |
||
80 | */ |
||
81 | public function set($array = [self::USER_AGENT]) |
||
95 | |||
96 | /** |
||
97 | * Add |
||
98 | * |
||
99 | * @param string $line |
||
100 | * @return bool |
||
101 | */ |
||
102 | public function add($line) |
||
124 | |||
125 | /** |
||
126 | * Export |
||
127 | * |
||
128 | * @return array |
||
129 | */ |
||
130 | public function export() |
||
144 | } |
||
145 |