本文整理汇总了PHP中Webmozart\Assert\Assert::nullOrNotEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::nullOrNotEmpty方法的具体用法?PHP Assert::nullOrNotEmpty怎么用?PHP Assert::nullOrNotEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Assert\Assert
的用法示例。
在下文中一共展示了Assert::nullOrNotEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates a new option.
*
* @param string $longName The long option name.
* @param string|null $shortName The short option name.
* @param int $flags A bitwise combination of the option flag
* constants.
* @param string $description A human-readable description of the option.
*
* @throws InvalidValueException If the default value is invalid.
*/
public function __construct($longName, $shortName = null, $flags = 0, $description = null)
{
$longName = $this->removeDoubleDashPrefix($longName);
$shortName = $this->removeDashPrefix($shortName);
Assert::nullOrString($description, 'The option description must be a string or null. Got: %s');
Assert::nullOrNotEmpty($description, 'The option description must not be empty.');
$this->assertFlagsValid($flags);
$this->assertLongNameValid($longName);
$this->assertShortNameValid($shortName, $flags);
$this->longName = $longName;
$this->shortName = $shortName;
$this->description = $description;
$this->addDefaultFlags($flags);
$this->flags = $flags;
}
示例2: __construct
/**
* Creates a new argument.
*
* @param string $name The argument name
* @param int $flags A bitwise combination of the flag constants.
* @param string $description A human-readable description of the argument.
* @param mixed $defaultValue The default value of the argument (must be
* null for the flag {@link self::REQUIRED}).
*/
public function __construct($name, $flags = 0, $description = null, $defaultValue = null)
{
Assert::string($name, 'The argument name must be a string. Got: %s');
Assert::notEmpty($name, 'The argument name must not be empty.');
Assert::startsWithLetter($name, 'The argument name must start with a letter.');
Assert::regex($name, '~^[a-zA-Z0-9\\-]+$~', 'The argument name must contain letters, digits and hyphens only.');
Assert::nullOrString($description, 'The argument description must be a string or null. Got: %s');
Assert::nullOrNotEmpty($description, 'The argument description must not be empty.');
$this->assertFlagsValid($flags);
$this->addDefaultFlags($flags);
$this->name = $name;
$this->flags = $flags;
$this->description = $description;
$this->defaultValue = $this->isMultiValued() ? array() : null;
if ($this->isOptional() || null !== $defaultValue) {
$this->setDefaultValue($defaultValue);
}
}