本文整理汇总了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;
}
示例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');
}
示例3: read
public function read($filename)
{
Assertion::file($filename);
$this->filename = $filename;
$config = (include $this->filename);
$this->assertConfigIsValid($config);
return $config;
}
示例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];
}
示例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;
}
示例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;
}
示例7: testFileDoesNotExists
public function testFileDoesNotExists()
{
$this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INVALID_FILE);
Assertion::file(__DIR__ . '/does-not-exists');
}
示例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));
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例14: configFromFile
/**
* @param string $filename
*
* @throws InvalidArgumentException
*
* @return $this
*/
public function configFromFile($filename)
{
Assertion::file($filename);
$this->readFileAndMergeConfig($filename);
return $this;
}
示例15: iHaveAConfigFileAt
/**
* @Given /^I have a config file at "([^"]*)"$/
*/
public function iHaveAConfigFileAt($arg1)
{
$this->configFilePath = getcwd() . "/{$arg1}/";
Assertion::file($this->configFilePath . 'quick-configure.json');
}