本文整理汇总了PHP中Webmozart\Assert\Assert::string方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::string方法的具体用法?PHP Assert::string怎么用?PHP Assert::string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Assert\Assert
的用法示例。
在下文中一共展示了Assert::string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addParticipation
/**
* Adds a participation to the data collector.
*
* @param string $testIdentifier It will look like "Qp0gahJ3RAO3DJ18b0XoUQ"
* @param int $variationIndex
* @throws InvalidArgumentException
*/
public function addParticipation($testIdentifier, $variationIndex)
{
Assert::string($testIdentifier, 'Test identifier must be a string');
Assert::integer($variationIndex, 'Variation index must be integer');
Assert::greaterThan($variationIndex, -1, 'Variation index must be integer >= 0');
$this->participations[$testIdentifier] = $variationIndex;
}
示例2: create
/**
* {@inheritdoc}
*/
public static function create($body, FqsenResolver $resolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
{
Assert::string($body);
Assert::allNotNull([$resolver, $descriptionFactory]);
$parts = preg_split('/\\s+/Su', $body, 2);
return new static($resolver->resolve($parts[0], $context), $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context));
}
示例3: convertNameToCode
/**
* {@inheritdoc}
*/
public function convertNameToCode($name, $locale = 'en')
{
$names = Intl::getLocaleBundle()->getLocaleNames($locale);
$code = array_search($name, $names, true);
Assert::string($code, sprintf('Cannot find code for "%s" locale name', $name));
return $code;
}
示例4: create
public static function create($body)
{
Assert::string($body);
$scope = preg_split('/(,?\\s+)/Su', $body);
$scope = array_filter($scope);
return new static($scope);
}
示例5: create
/**
* Creates a new tag that represents any unknown tag type.
*
* @param string $body
* @param string $name
* @param DescriptionFactory $descriptionFactory
* @param Context $context
*
* @return static
*/
public static function create($body, $name = '', DescriptionFactory $descriptionFactory = null, Context $context = null)
{
Assert::string($body);
Assert::stringNotEmpty($name);
$description = $descriptionFactory && $body ? $descriptionFactory->create($body, $context) : null;
return new static($name, $description);
}
示例6: __construct
/**
* @param string $variableName
* @param Type $type
* @param Description $description
*/
public function __construct($variableName, Type $type = null, Description $description = null)
{
Assert::string($variableName);
$this->variableName = $variableName;
$this->type = $type;
$this->description = $description;
}
示例7: create
/**
* {@inheritdoc}
*/
public static function create($body, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
{
Assert::string($body);
Assert::notNull($descriptionFactory);
$parts = preg_split('/\\s+/Su', $body, 2);
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
return new static($parts[0], $description);
}
示例8: doDelete
private function doDelete($name)
{
Assert::string($name, "Name must be a string. Got: %s");
foreach ((yield \Amp\File\scandir($this->root . "/" . $name)) as $file) {
(yield \Amp\File\unlink($this->root . "/" . $name . "/" . $file));
}
(yield \Amp\File\rmdir($this->root . "/" . $name));
}
示例9: doDelete
private function doDelete($token)
{
Assert::string($token, "Token must be a string. Got: %s");
$path = $this->docroot . "/.well-known/acme-challenge/{$token}";
$realpath = realpath($path);
if ($realpath) {
(yield \Amp\File\unlink($realpath));
}
}
示例10: create
public static function create($body)
{
Assert::string($body);
$parts = preg_split('/(\\n+)/Su', $body, 2);
if (!empty($parts[0])) {
$group = array_shift($parts);
}
return new static($group);
}
示例11: __construct
/**
* @param string $variableName
* @param Type $type
* @param bool $isVariadic
* @param Description $description
*/
public function __construct($variableName, Type $type = null, $isVariadic = false, Description $description = null)
{
Assert::string($variableName);
Assert::boolean($isVariadic);
$this->variableName = $variableName;
$this->type = $type;
$this->isVariadic = $isVariadic;
$this->description = $description;
}
示例12: __construct
/**
* Create a Serializer instance.
*
* @param int $indent The number of times the indent string is repeated.
* @param string $indentString The string to indent the comment with.
* @param bool $indentFirstLine Whether to indent the first line.
* @param int|null $lineLength The max length of a line or NULL to disable line wrapping.
*/
public function __construct($indent = 0, $indentString = ' ', $indentFirstLine = true, $lineLength = null)
{
Assert::integer($indent);
Assert::string($indentString);
Assert::boolean($indentFirstLine);
Assert::nullOrInteger($lineLength);
$this->indent = $indent;
$this->indentString = $indentString;
$this->isFirstLineIndented = $indentFirstLine;
$this->lineLength = $lineLength;
}
示例13: __construct
/**
* Creates a new package DTO.
*
* @param string $name The package name.
* @param string $installerName The name of the installer.
* @param string $installPath The absolute install path.
* @param string $state One of the STATE_* constants in this class.
*/
public function __construct($name, $installerName, $installPath, $state)
{
Assert::stringNotEmpty($name, 'The package name must be a non-empty string. Got: %s');
Assert::string($installerName, 'The installer name must be a string. Got: %s');
Assert::stringNotEmpty($installPath, 'The install path must be a non-empty string. Got: %s');
Assert::oneOf($state, self::$states, 'The package state must be one of %2$s. Got: %s');
$this->name = $name;
$this->installerName = $installerName;
$this->installPath = $installPath;
$this->state = $state;
}
示例14: create
public static function create($body, Context $context = null)
{
Assert::string($body);
$parts = preg_split('/(\\s+)/Su', $body, 1);
if (!empty($parts[0])) {
$key = array_shift($parts);
} else {
$key = null;
}
return new static($key);
}
示例15: create
/**
* Attempts to create a new Author object based on †he tag body.
*
* @param string $body
*
* @return static
*/
public static function create($body)
{
Assert::string($body);
$splitTagContent = preg_match('/^([^\\<]*)(?:\\<([^\\>]*)\\>)?$/u', $body, $matches);
if (!$splitTagContent) {
return null;
}
$authorName = trim($matches[1]);
$email = isset($matches[2]) ? trim($matches[2]) : '';
return new static($authorName, $email);
}