1 | <?php |
||
15 | class Rules implements \Countable |
||
16 | { |
||
17 | const DEFAULT_UA = '*'; |
||
18 | |||
19 | /** |
||
20 | * The collection of rules |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $collection = []; |
||
24 | |||
25 | protected $sitemaps = []; |
||
26 | |||
27 | /** |
||
28 | * Default rule used if robots.txt is empty |
||
29 | * @var Rule |
||
30 | */ |
||
31 | private $defaultRule; |
||
32 | |||
33 | public function __construct() |
||
38 | |||
39 | public function addSitemap($sitemap) |
||
47 | |||
48 | public function getSitemaps() |
||
52 | |||
53 | /** |
||
54 | * Add a new rule to the collection |
||
55 | * @param Rule $rule |
||
56 | * @return Rules |
||
57 | */ |
||
58 | public function add(Rule $rule) |
||
72 | |||
73 | /** |
||
74 | * Check if the URL match for the given UA or not |
||
75 | * @param string $userAgent |
||
76 | * @param string $url |
||
77 | * @return boolean |
||
78 | */ |
||
79 | public function match($userAgent, $url) |
||
83 | |||
84 | /** |
||
85 | * Retrieve rules for a given UA |
||
86 | * @param string $userAgent |
||
87 | * @return null|Rule |
||
88 | */ |
||
89 | public function get($userAgent) |
||
110 | |||
111 | /** |
||
112 | * Update the UA to make a valid regexp |
||
113 | * @param string $userAgent |
||
114 | * @return string |
||
115 | */ |
||
116 | private function handleUa($userAgent) |
||
123 | |||
124 | /** |
||
125 | * Return the number of rules |
||
126 | * @return integer |
||
127 | */ |
||
128 | public function count() |
||
132 | } |
||
133 |