本文整理匯總了PHP中Puli\Manager\Assert\Assert::integer方法的典型用法代碼示例。如果您正苦於以下問題:PHP Assert::integer方法的具體用法?PHP Assert::integer怎麽用?PHP Assert::integer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Puli\Manager\Assert\Assert
的用法示例。
在下文中一共展示了Assert::integer方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: generateNewInstance
/**
* {@inheritdoc}
*/
public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
{
$options = array_replace(self::$defaultOptions, $options);
Assert::string($options['host'], 'The host must be a string. Got: %s');
Assert::integer($options['port'], 'The port must be an integer. Got: %s');
$escHost = var_export($options['host'], true);
$escPort = var_export($options['port'], true);
$targetMethod->getClass()->addImports(array(new Import('Redis'), new Import('Webmozart\\KeyValueStore\\PhpRedisStore')));
$targetMethod->addBody(<<<EOF
\$client = new Redis();
\$client->connect({$escHost}, {$escPort});
\${$varName} = new PhpRedisStore(\$client);
EOF
);
}
示例2: generateNewInstance
/**
* {@inheritdoc}
*/
public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
{
$options = array_replace(self::$defaultOptions, $options);
Assert::stringNotEmpty($options['host'], 'The "host" option must be a non-empty string. Got: %s');
Assert::integer($options['port'], 'The "port" option must be an integer. Got: %s');
$escHost = var_export($options['host'], true);
$escPort = var_export($options['port'], true);
$targetMethod->getClass()->addImports(array(new Import('Predis\\Client'), new Import('Webmozart\\KeyValueStore\\PredisStore')));
$targetMethod->addBody(<<<EOF
\$client = new Client(array(
'host' => {$escHost},
'port' => {$escPort},
));
\${$varName} = new PredisStore(\$client);
EOF
);
}
示例3: generateNewInstance
/**
* {@inheritdoc}
*/
public function generateNewInstance($varName, Method $targetMethod, GeneratorRegistry $generatorRegistry, array $options = array())
{
Assert::keyExists($options, 'bucket', 'The "bucket" option is missing.');
$options = array_replace(self::$defaultOptions, $options);
Assert::string($options['bucket'], 'The bucket must be a string. Got: %s');
Assert::string($options['host'], 'The host must be a string. Got: %s');
Assert::integer($options['port'], 'The port must be an integer. Got: %s');
$escBucket = var_export($options['bucket'], true);
$escHost = var_export($options['host'], true);
$escPort = var_export($options['port'], true);
$targetMethod->getClass()->addImports(array(new Import('Basho\\Riak\\Riak'), new Import('Webmozart\\KeyValueStore\\RiakStore')));
$targetMethod->addBody(<<<EOF
\$client = new Riak({$escHost}, {$escPort});
\${$varName} = new RiakStore({$escBucket}, \$client);
EOF
);
}
示例4: addRootBindingType
/**
* {@inheritdoc}
*/
public function addRootBindingType(BindingTypeDescriptor $typeDescriptor, $flags = 0)
{
Assert::integer($flags, 'The argument $flags must be a boolean.');
$this->assertPackagesLoaded();
$this->emitWarningForDuplicateTypes();
if (!($flags & self::OVERRIDE) && $this->typeDescriptors->contains($typeDescriptor->getName())) {
throw DuplicateTypeException::forTypeName($typeDescriptor->getName());
}
$tx = new Transaction();
try {
$typeName = $typeDescriptor->getName();
$syncBindingOps = array();
foreach ($this->getUuidsByTypeName($typeName) as $uuid) {
$syncBindingOp = $this->syncBindingUuid($uuid);
$syncBindingOp->takeSnapshot();
$syncBindingOps[] = $syncBindingOp;
}
$syncOp = $this->syncTypeName($typeName);
$syncOp->takeSnapshot();
$tx->execute($this->loadTypeDescriptor($typeDescriptor, $this->rootPackage));
$tx->execute($this->addTypeDescriptorToPackageFile($typeDescriptor));
$tx->execute($syncOp);
foreach ($syncBindingOps as $syncBindingOp) {
$tx->execute($syncBindingOp);
}
$this->saveRootPackageFile();
$tx->commit();
} catch (Exception $e) {
$tx->rollback();
throw $e;
}
}
示例5: addRootPathMapping
/**
* {@inheritdoc}
*/
public function addRootPathMapping(PathMapping $mapping, $flags = 0)
{
Assert::integer($flags, 'The argument $flags must be a boolean.');
$this->assertMappingsLoaded();
if (!($flags & self::OVERRIDE) && $this->rootPackageFile->hasPathMapping($mapping->getRepositoryPath())) {
throw DuplicatePathMappingException::forRepositoryPath($mapping->getRepositoryPath(), $this->rootPackage->getName());
}
$tx = new Transaction();
try {
$syncOp = $this->syncRepositoryPath($mapping->getRepositoryPath());
$syncOp->takeSnapshot();
$tx->execute($this->loadPathMapping($mapping, $this->rootPackage));
if (!($flags & self::IGNORE_FILE_NOT_FOUND)) {
$this->assertNoLoadErrors($mapping);
}
$tx->execute($this->updateConflicts($mapping->listRepositoryPaths()));
$tx->execute($this->overrideConflictingPackages($mapping));
$tx->execute($this->updateConflicts());
$tx->execute($this->addPathMappingToPackageFile($mapping));
$tx->execute($syncOp);
$this->saveRootPackageFile();
$tx->commit();
} catch (Exception $e) {
$tx->rollback();
throw $e;
}
}