本文整理汇总了PHP中Assert\Assertion::string方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::string方法的具体用法?PHP Assertion::string怎么用?PHP Assertion::string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPath
private function setPath($path)
{
Assertion::string($path);
Assertion::regex($path, '|(?mi-Us)^(/[a-zA-Z][a-zA-Z0-9_-]*)+(/@[a-zA-Z][a-zA-Z0-9_-]*)?$|');
$this->path = $path;
return $this;
}
示例2: setName
/**
* @param string $name
*/
protected function setName($name)
{
Assertion::string($name);
Assertion::notBlank($name);
$this->attributes['name'] = $name;
$this->name = $name;
}
示例3: withName
/**
* @param string $workflowName
* @param string $workflowId
* @return CreateWorkflow
*/
public static function withName($workflowName, $workflowId)
{
Assertion::string($workflowName);
Assertion::notEmpty($workflowName);
Assertion::uuid($workflowId);
return new self(__CLASS__, ['workflow_id' => $workflowId, 'name' => $workflowName]);
}
示例4: __construct
/**
* @param MappingInterface[] $mappings
*/
public function __construct(array $mappings, string $className, callable $apply = null, callable $unapply = null)
{
foreach ($mappings as $mappingKey => $mapping) {
Assertion::string($mappingKey);
Assertion::isInstanceOf($mapping, MappingInterface::class);
$this->mappings[$mappingKey] = $mapping->withPrefixAndRelativeKey($this->key, $mappingKey);
}
Assertion::classExists($className);
if (null === $apply) {
$apply = function (...$arguments) {
return new $this->className(...array_values($arguments));
};
}
if (null === $unapply) {
$unapply = function ($value) {
Assertion::isInstanceOf($value, $this->className);
$values = [];
$reflectionClass = new ReflectionClass($this->className);
foreach ($reflectionClass->getProperties() as $property) {
/* @var $property ReflectionProperty */
$property->setAccessible(true);
$values[$property->getName()] = $property->getValue($value);
}
return $values;
};
}
$this->className = $className;
$this->apply = $apply;
$this->unapply = $unapply;
}
示例5: setFilename
/**
* @param string $filename
*/
public function setFilename($filename)
{
Assertion::string($filename, 'Invalid filename.');
Assertion::directory(dirname($filename), 'The selected directory does not exist.');
Assertion::writeable(dirname($filename), 'The selected directory is not writable.');
$this->filename = $filename;
}
示例6: __construct
/**
* @param string $text
* @param callable $selectAction
* @param bool $showItemExtra
*/
public function __construct($text, callable $selectAction, $showItemExtra = false)
{
Assertion::string($text);
$this->text = $text;
$this->selectAction = $selectAction;
$this->showItemExtra = (bool) $showItemExtra;
}
示例7: setToken
/**
* Устанавливает описание gitlab'a
*
* @param string $token
*
* @return $this
* @throws \Assert\AssertionFailedException
*/
public function setToken($token)
{
Assertion::notEmpty($token);
Assertion::string($token);
$this->token = $token;
return $this;
}
示例8: withData
/**
* @param string $aggregateType
* @param string $aggregateId
* @param int $version
* @return TakeSnapshot
*/
public static function withData($aggregateType, $aggregateId, $version)
{
Assertion::string($aggregateType);
Assertion::string($aggregateId);
Assertion::min($version, 1);
return new self(['aggregate_type' => $aggregateType, 'aggregate_id' => $aggregateId, 'version' => $version]);
}
示例9: __construct
/**
* @param string $value
*/
public function __construct($value)
{
Assertion::string($value);
Assertion::minLength($value, 1);
Assertion::maxLength($value, 50);
$this->value = strtolower($value);
}
示例10: createExchangePipeline
protected function createExchangePipeline(MigrationTargetInterface $migration_target, $exchange_name)
{
Assertion::string($exchange_name);
$wait_exchange_name = $exchange_name . self::WAIT_SUFFIX;
$wait_queue_name = $wait_exchange_name . self::QUEUE_SUFFIX;
$unrouted_exchange_name = $exchange_name . self::UNROUTED_SUFFIX;
$unrouted_queue_name = $unrouted_exchange_name . self::QUEUE_SUFFIX;
$repub_exchange_name = $exchange_name . self::REPUB_SUFFIX;
$repub_queue_name = $repub_exchange_name . self::QUEUE_SUFFIX;
$channel = $this->getConnection($migration_target)->channel();
// Setup the default exchange and queue pipelines
$channel->exchange_declare($unrouted_exchange_name, 'fanout', false, true, false, true);
//internal
$channel->exchange_declare($repub_exchange_name, 'fanout', false, true, false, true);
//internal
$channel->exchange_declare($wait_exchange_name, 'fanout', false, true, false);
$channel->exchange_declare($exchange_name, 'direct', false, true, false, false, false, ['alternate-exchange' => ['S', $unrouted_exchange_name]]);
$channel->queue_declare($wait_queue_name, false, true, false, false, false, ['x-dead-letter-exchange' => ['S', $exchange_name]]);
$channel->queue_bind($wait_queue_name, $wait_exchange_name);
$channel->queue_declare($unrouted_queue_name, false, true, false, false, false, ['x-dead-letter-exchange' => ['S', $repub_exchange_name], 'x-message-ttl' => ['I', self::REPUB_INTERVAL]]);
$channel->queue_bind($unrouted_queue_name, $unrouted_exchange_name);
$channel->queue_declare($repub_queue_name, false, true, false, false);
$channel->queue_bind($repub_queue_name, $repub_exchange_name);
$this->createShovel($migration_target, $repub_exchange_name, $exchange_name, $repub_queue_name);
}
示例11: getProjectConfig
/**
* Returns a project config instance.
*
* @param string $project Project name
*
* @return Config
*/
public function getProjectConfig($project)
{
Assertion::string($project);
Assertion::notEmpty($project);
$config = $this->configLoader->load(array($this->getConfigFilePath($project)));
return $config;
}
示例12: fromString
/**
* Initializes and returns a coordinate object with the specified coordinate information in string format.
*
* Valid format:
* "latitude in degrees, longitude in degrees"
*
* Example:
* "51.3703748, 6.1724031"
*
* Please note that UTM and MGRS coordinates are not yet supported!
*
* @param $coordinate Coordinate information in string format
*
* @return static
*/
public static function fromString($coordinate)
{
Assertion::string($coordinate);
Assertion::true(substr_count($coordinate, ',') === 1);
$coordinate = explode(',', $coordinate);
return new static((double) $coordinate[0], (double) $coordinate[1]);
}
示例13: addOptions
private function addOptions(DOMDocument $document, DOMNode $node, array $options, array $selectedValues)
{
foreach ($options as $value => $label) {
if (is_int($value)) {
$value = (string) $value;
} else {
Assertion::string($value);
}
Assertion::true(is_string($label) || is_array($label));
if (is_array($label)) {
$optgroup = $document->createElement('optgroup');
$this->addAttributes($optgroup, ['label' => $value]);
$this->addOptions($document, $optgroup, $label, $selectedValues);
$node->appendChild($optgroup);
continue;
}
$option = $document->createElement('option');
$option->appendChild($document->createTextNode($label));
$htmlAttributes = ['value' => $value];
if (in_array($value, $selectedValues)) {
$htmlAttributes['selected'] = 'selected';
}
$this->addAttributes($option, $htmlAttributes);
$node->appendChild($option);
}
}
示例14: __construct
/**
* @param string $type
* @param string $code
*/
public function __construct($type, $code)
{
Assertion::inArray($type, $this->types);
Assertion::string($code);
$this->type = $type;
$this->code = $code;
}
示例15: normalize
/**
* @param string $messageName
* @return string
*/
public static function normalize($messageName)
{
Assertion::notEmpty($messageName);
Assertion::string($messageName);
$search = array(static::MESSAGE_NAME_PREFIX, "-", "\\", "/", " ");
return strtolower(str_replace($search, "", $messageName));
}