Inheritance: extends Exceptio\Exception
Exemple #1
0
 /**
  * @param string $yamlFile
  * @param bool $backupBeforeOverride
  * @throws FileNotFoundException
  */
 public function convertFile($yamlFile, $backupBeforeOverride = true)
 {
     if (!$this->fs->exists($yamlFile)) {
         throw FileNotFoundException::fileNotFound($yamlFile);
     }
     $this->doConvert(Yaml::parse(file_get_contents($yamlFile)), $backupBeforeOverride);
 }
Exemple #2
0
 /**
  * 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);
 }