diff --git a/lib/Check/UserAgentCheck.php b/lib/Check/UserAgentCheck.php index fbe1223..32807c5 100644 --- a/lib/Check/UserAgentCheck.php +++ b/lib/Check/UserAgentCheck.php @@ -32,6 +32,26 @@ class UserAgentCheck extends AbstractCheck */ protected $bots = []; + /** + * Constructor. + * + * @param UserAgentInterface[] $userAgents The UserAgent objects to use + * + * @throws \InvalidArgumentException If an unsupported user agent type is given. + */ + public function __construct(array $userAgents = []) + { + foreach ($userAgents as $userAgent) { + if ($userAgent instanceof BrowserInterface) { + $this->browsers[] = $userAgent; + } elseif ($userAgent instanceof BotInterface) { + $this->bots[] = $userAgent; + } else { + throw new \InvalidArgumentException('Unsupported user agent type'); + } + } + } + /** * {@inheritdoc} */