discardDetails = true; } /** * Parses the current UA and checks whether it contains bot information * * @return array|null * * @throws \Exception * * @see bots.yml for list of detected bots * * Step 1: Build a big regex containing all regexes and match UA against it * -> If no matches found: return * -> Otherwise: * Step 2: Walk through the list of regexes in bots.yml and try to match every one * -> Return the matched data * * If $discardDetails is set to TRUE, the Step 2 will be skipped * $bot will be set to TRUE instead * * NOTE: Doing the big match before matching every single regex speeds up the detection * */ public function parse(): ?array { $result = null; if ($this->preMatchOverall()) { if ($this->discardDetails) { return [true]; } foreach ($this->getRegexes() as $regex) { $matches = $this->matchUserAgent($regex['regex']); if (!$matches) { continue; } unset($regex['regex']); $result = $regex; if (\array_key_exists('name', $result)) { $result['name'] = $this->buildByMatch($result['name'], $matches); } break; } } return $result; } }