/**
* Start up the parser by importing the json file to $this->regexes
*
* @param string|array $customRegexesFileOrArray
* @throws FileNotFoundException
*/
public function __construct($customRegexesFileOrArray = null)
{
if (is_string($customRegexesFileOrArray) || $customRegexesFileOrArray === null) {
$regexesFile = $customRegexesFileOrArray !== null ? $customRegexesFileOrArray : static::getDefaultFile();
if (file_exists($regexesFile)) {
$this->regexes = (include $regexesFile);
} elseif ($customRegexesFileOrArray !== null) {
throw FileNotFoundException::customRegexFileNotFound($regexesFile);
} else {
throw FileNotFoundException::defaultFileNotFound(static::getDefaultFile());
}
trigger_error('Using the constructor is deprecated. Use Parser::create(string $file = null) instead', E_USER_DEPRECATED);
} elseif (is_array($customRegexesFileOrArray)) {
$this->regexes = $customRegexesFileOrArray;
} else {
throw InvalidArgumentException::unexpectedArgument('array', gettype($customRegexesFileOrArray), 0, __METHOD__);
}
$this->deviceParser = new DeviceParser($this->regexes);
$this->operatingSystemParser = new OperatingSystemParser($this->regexes);
$this->userAgentParser = new UserAgentParser($this->regexes);
}