コード例 #1
0
ファイル: PhpSetting.php プロジェクト: crossjoin/browscap
 /**
  * PhpBrowscapIni constructor.
  *
  * @throws SourceConditionNotSatisfiedException
  * @throws SourceUnavailableException
  */
 public function __construct()
 {
     $iniPath = $this->getIniPath();
     if ($iniPath !== '') {
         parent::__construct($iniPath);
     } else {
         throw new SourceConditionNotSatisfiedException("Browscap file not configured in php configuration (see 'browscap' directive).", 1458977060);
     }
 }
コード例 #2
0
ファイル: FileTest.php プロジェクト: crossjoin/browscap
 /**
  * @expectedException \Crossjoin\Browscap\Exception\SourceUnavailableException
  * @expectedExceptionCode 1458977225
  *
  * @throws ParserRuntimeException
  * @throws SourceUnavailableException
  */
 public function testDataSourceUnavailable()
 {
     $iniFile = dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'lite_php_browscap.ini';
     $tmpFile = tempnam(sys_get_temp_dir(), 'cb-');
     file_put_contents($tmpFile, file_get_contents($iniFile));
     $source = new File($tmpFile);
     unlink($tmpFile);
     $content = '';
     foreach ($source->getDataSets() as $dataSet) {
         // do nothing, but this loop is required to really call getData()
         $content .= ' ';
     }
 }