当前位置: 首页>>代码示例>>PHP>>正文


PHP Assertion::file方法代码示例

本文整理汇总了PHP中Assert\Assertion::file方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::file方法的具体用法?PHP Assertion::file怎么用?PHP Assertion::file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Assert\Assertion的用法示例。


在下文中一共展示了Assertion::file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * It should be instantiated with the title of
  * the workshop and the path to the DI configuration file.
  *
  * @param string $workshopTitle The workshop title - this is used throughout the application
  * @param string $diConfigFile The absolute path to the DI configuration file
  */
 public function __construct($workshopTitle, $diConfigFile)
 {
     Assertion::string($workshopTitle);
     Assertion::file($diConfigFile);
     $this->workshopTitle = $workshopTitle;
     $this->diConfigFile = $diConfigFile;
 }
开发者ID:php-school,项目名称:php-workshop,代码行数:14,代码来源:Application.php

示例2: iHaveSomeGeneratedConfigAt

 /**
  * @Given /^I have some generated config at "([^"]*)"$/
  */
 public function iHaveSomeGeneratedConfigAt($arg1)
 {
     $this->configFilePath = getcwd() . "/{$arg1}/";
     Assertion::file($this->configFilePath . 'configured.json');
     $this->config = json_decode(file_get_contents($this->configFilePath . 'configured.json'));
     Assertion::isInstanceOf($this->config, 'stdClass');
 }
开发者ID:benconstable,项目名称:quick-configure,代码行数:10,代码来源:FeatureContext.php

示例3: read

 public function read($filename)
 {
     Assertion::file($filename);
     $this->filename = $filename;
     $config = (include $this->filename);
     $this->assertConfigIsValid($config);
     return $config;
 }
开发者ID:tomphp,项目名称:config-service-provider,代码行数:8,代码来源:PHPFileReader.php

示例4: create

 /**
  * @param string $filename
  *
  * @throws InvalidArgumentException
  *
  * @return FileReader
  */
 public function create($filename)
 {
     Assertion::file($filename);
     $readerClass = $this->getReaderClass($filename);
     if (!isset($this->readers[$readerClass])) {
         $this->readers[$readerClass] = new $readerClass();
     }
     return $this->readers[$readerClass];
 }
开发者ID:tomphp,项目名称:config-service-provider,代码行数:16,代码来源:ReaderFactory.php

示例5: read

 public function read($filename)
 {
     Assertion::file($filename);
     $this->filename = $filename;
     $config = json_decode(file_get_contents($filename), true);
     if (json_last_error() !== JSON_ERROR_NONE) {
         throw InvalidConfigException::fromJSONFileError($filename, $this->getJsonError());
     }
     return $config;
 }
开发者ID:tomphp,项目名称:config-service-provider,代码行数:10,代码来源:JSONFileReader.php

示例6: marshallInput

 protected function marshallInput(InputInterface $input) : string
 {
     $inputFile = $input->getArgument('file');
     if ($inputFile) {
         Assertion::file($inputFile);
         $inputBuffer = file_get_contents($inputFile);
     } else {
         $inputBuffer = '';
         $stdin = fopen('php://stdin', 'r');
         stream_set_blocking($stdin, false);
         while ($line = fgets($stdin)) {
             $inputBuffer .= $line;
         }
     }
     Assertion::notEmpty($inputBuffer, 'Input must not be empty');
     return $inputBuffer;
 }
开发者ID:stefanotorresi,项目名称:thorr-advent,代码行数:17,代码来源:PuzzleCommand.php

示例7: testFileDoesNotExists

 public function testFileDoesNotExists()
 {
     $this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INVALID_FILE);
     Assertion::file(__DIR__ . '/does-not-exists');
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:5,代码来源:AssertTest.php

示例8: fromFile

 /**
  * Creates a new Doc with the DocStream set to the content of
  * the specified file path.
  *
  * @param $DocType
  * @param $DocMimeType
  * @param $FilePath
  * @return Doc
  *
  * @throws \InvalidArgumentException If the file does not exist or is not readable.
  */
 public static function fromFile($DocType, $DocMimeType, $FilePath)
 {
     Assertion::file($FilePath, "{$FilePath} does not exist.");
     Assertion::readable($FilePath, "{$FilePath} is not readable.");
     return new self($DocType, $DocMimeType, file_get_contents($FilePath));
 }
开发者ID:swisspost-yellowcube,项目名称:yellowcube-php,代码行数:17,代码来源:Doc.php

示例9: parseConfigFile

 /**
  * Parses config file and returns array.
  *
  * @param string $file
  *
  * @return array
  */
 private function parseConfigFile($file)
 {
     Assertion::file($file, 'Can\'t parse config file. File does not exist: ' . $file);
     $config = Yaml::parse(file_get_contents($file));
     if (is_null($config)) {
         $config = array();
     }
     return $config;
 }
开发者ID:andreas-weber,项目名称:php-config,代码行数:16,代码来源:ConfigLoader.php

示例10: create

 public function create($key, $description)
 {
     $ret = false;
     try {
         $prefix = Carbon::now()->format('YmdHis');
         $keys = $this->getSlugKeyName($key);
         $classname = $keys . "Migration";
         $filename = MIGRATIONPATH . DS . $classname . ".php";
         $classtxt = Stringy::create($this->migration_model)->replace("##description##", $description)->replace("##date##", $prefix)->replace('##classname##', $classname)->replace('##key##', $keys)->__toString();
         file_put_contents($filename, $classtxt);
         Assertion::file($filename);
         $ret = true;
     } catch (\Exception $e) {
         $ret = false;
     } catch (AssertionFailedException $ex) {
         $ret = false;
     }
     return $ret;
 }
开发者ID:kletellier,项目名称:mvc,代码行数:19,代码来源:Migrator.php

示例11: putLargeBlob

 /**
  * Put large blob (> 64 MB)
  *
  * @param string $containerName Container name
  * @param string $blobName Blob name
  * @param string $localFileName Local file name to be uploaded
  * @param array  $metadata      Key/value pairs of meta data
  * @param string $leaseId       Lease identifier
  * @param array  $additionalHeaders  Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
  * @return object Partial blob properties
  * @throws BlobException
  */
 public function putLargeBlob($containerName = '', $blobName = '', $localFileName = '', $metadata = array(), $leaseId = null, $additionalHeaders = array())
 {
     Assertion::notEmpty($containerName, 'Container name is not specified');
     self::assertValidContainerName($containerName);
     Assertion::notEmpty($blobName, 'Blob name is not specified.');
     Assertion::notEmpty($localFileName, 'Local file name is not specified.');
     Assertion::file($localFileName, 'Local file name is not specified.');
     self::assertValidRootContainerBlobName($containerName, $blobName);
     if (filesize($localFileName) < self::MAX_BLOB_SIZE) {
         return $this->putBlob($containerName, $blobName, $localFileName, $metadata, $leaseId, $additionalHeaders);
     }
     $numberOfParts = ceil(filesize($localFileName) / self::MAX_BLOB_TRANSFER_SIZE);
     $blockIdentifiers = array();
     for ($i = 0; $i < $numberOfParts; $i++) {
         $blockIdentifiers[] = $this->generateBlockId($i);
     }
     $fp = fopen($localFileName, 'r');
     if ($fp === false) {
         throw new BlobException('Could not open local file.');
     }
     for ($i = 0; $i < $numberOfParts; $i++) {
         fseek($fp, $i * self::MAX_BLOB_TRANSFER_SIZE);
         $fileContents = fread($fp, self::MAX_BLOB_TRANSFER_SIZE);
         $this->putBlock($containerName, $blobName, $blockIdentifiers[$i], $fileContents, $leaseId);
         $fileContents = null;
         unset($fileContents);
     }
     fclose($fp);
     $this->putBlockList($containerName, $blobName, $blockIdentifiers, $metadata, $leaseId, $additionalHeaders);
     return $this->getBlobInstance($containerName, $blobName, null, $leaseId);
 }
开发者ID:achretien,项目名称:azure-blob-storage,代码行数:43,代码来源:BlobClient.php

示例12: getConfigFilePath

 /**
  * Returns a config file path.
  *
  * @param0 string $project Project name
  *
  * @return string
  */
 private function getConfigFilePath($project)
 {
     $path = $this->path . '/' . $project . '.yml';
     Assertion::file($path);
     return realpath($path);
 }
开发者ID:mykanoa,项目名称:kanoa,代码行数:13,代码来源:ConfigHandler.php

示例13: setCertificateFilePath

 /**
  * Sets a certificate file path and optional passphrase to use.
  *
  * @param string $certificateFilePath Path to a certificate file.
  * @return Config
  *
  * @throws \InvalidArgumentException If certificate path is invalid.
  */
 public function setCertificateFilePath($certificateFilePath, $passphrase = null)
 {
     Assertion::file($certificateFilePath);
     Assertion::readable($certificateFilePath);
     $this->certificateFilePath = $certificateFilePath;
     $this->soapClientOptions['local_cert'] = $certificateFilePath;
     if (!empty($passphrase)) {
         $this->soapClientOptions['passphrase'] = $passphrase;
     }
     return $this;
 }
开发者ID:swisspost-yellowcube,项目名称:yellowcube-php,代码行数:19,代码来源:Config.php

示例14: configFromFile

 /**
  * @param string $filename
  *
  * @throws InvalidArgumentException
  *
  * @return $this
  */
 public function configFromFile($filename)
 {
     Assertion::file($filename);
     $this->readFileAndMergeConfig($filename);
     return $this;
 }
开发者ID:tomphp,项目名称:config-service-provider,代码行数:13,代码来源:Configurator.php

示例15: iHaveAConfigFileAt

 /**
  * @Given /^I have a config file at "([^"]*)"$/
  */
 public function iHaveAConfigFileAt($arg1)
 {
     $this->configFilePath = getcwd() . "/{$arg1}/";
     Assertion::file($this->configFilePath . 'quick-configure.json');
 }
开发者ID:benconstable,项目名称:quick-configure,代码行数:8,代码来源:CommandConfigureContext.php


注:本文中的Assert\Assertion::file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。