1 | <?php |
||
12 | class UserAgent implements DirectiveInterface, RobotsTxtInterface |
||
13 | { |
||
14 | use ObjectTools; |
||
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 = 'User-agent'; |
||
30 | |||
31 | /** |
||
32 | * Current User-agent(s) |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $userAgent = []; |
||
36 | |||
37 | /** |
||
38 | * All User-agents declared |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $userAgents = []; |
||
42 | |||
43 | /** |
||
44 | * Rule array |
||
45 | * @var array |
||
46 | */ |
||
47 | protected $array = []; |
||
48 | |||
49 | /** |
||
50 | * Sub-directive Allow |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $allow = []; |
||
54 | |||
55 | /** |
||
56 | * Sub-directive Cache-delay |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $cacheDelay = []; |
||
60 | |||
61 | /** |
||
62 | * Sub-directive Crawl-delay |
||
63 | * @var array |
||
64 | */ |
||
65 | protected $crawlDelay = []; |
||
66 | |||
67 | /** |
||
68 | * Sub-directive Disallow |
||
69 | * @var array |
||
70 | */ |
||
71 | protected $disallow = []; |
||
72 | |||
73 | /** |
||
74 | * UserAgent constructor. |
||
75 | * |
||
76 | * @param null $parent |
||
77 | */ |
||
78 | public function __construct($parent = null) |
||
82 | |||
83 | /** |
||
84 | * Set new User-agent |
||
85 | * |
||
86 | * @param string $line |
||
87 | * @param bool $append |
||
88 | * @return bool |
||
89 | */ |
||
90 | public function set($line = self::USER_AGENT, $append = false) |
||
105 | |||
106 | /** |
||
107 | * Add |
||
108 | * |
||
109 | * @param string $line |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function add($line) |
||
134 | |||
135 | /** |
||
136 | * Check |
||
137 | * |
||
138 | * @param string $url - URL to check |
||
139 | * @param string $type - directive to check |
||
140 | * @return bool |
||
141 | */ |
||
142 | public function check($url, $type) |
||
152 | |||
153 | /** |
||
154 | * Export |
||
155 | * |
||
156 | * @return array |
||
157 | */ |
||
158 | public function export() |
||
172 | } |
||
173 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.