_rule[$this->_regex(trim($part[1]))] = true; } if (false !== strpos($part[0], 'disallow')) { $this->_rule[$this->_regex(trim($part[1]))] = false; } } } // User-agent * end if ($read && preg_match('!^user-agent:!', $row)) { break; } } } public function uriAllowed(string $uri) { // Unify case match $uri = strtolower(trim($uri)); // Index by default $result = true; // Begin index rules by ASC priority foreach ($this->_rule as $rule => $value) { if (preg_match('!^' . $rule . '!', $uri)) { $result = $value; } } return $result; } private function _regex(string $string) { return str_replace( [ '*', '?' ], [ '.*', '\?' ], $string ); } }