Jaybizzle\CrawlerDetect\CrawlerDetect::isCrawler PHP Method

isCrawler() public method

Check user agent string against the regex.
public isCrawler ( string $userAgent = null ) : boolean
$userAgent string
return boolean
    public function isCrawler($userAgent = null)
    {
        $agent = $userAgent ?: $this->userAgent;
        $agent = preg_replace('/' . $this->getExclusions() . '/i', '', $agent);
        if (strlen(trim($agent)) == 0) {
            return false;
        }
        $result = preg_match('/' . $this->getRegex() . '/i', trim($agent), $matches);
        if ($matches) {
            $this->matches = $matches;
        }
        return (bool) $result;
    }

Usage Example

Example #1
0
 /**
  * Check if current request is from a bot.
  *
  * @return bool
  */
 public function isRobot()
 {
     return $this->detector->isCrawler();
 }
All Usage Examples Of Jaybizzle\CrawlerDetect\CrawlerDetect::isCrawler