本文整理汇总了PHP中Assert\Assertion::maxLength方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::maxLength方法的具体用法?PHP Assertion::maxLength怎么用?PHP Assertion::maxLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::maxLength方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param $name
*/
public function __construct($name)
{
Assertion::string($name, 'StreamName must be a string');
Assertion::notEmpty($name, 'StreamName must not be empty');
Assertion::maxLength($name, 200, 'StreamName should not be longer than 200 chars');
$this->name = $name;
}
示例2: __construct
/**
* @param $text
*/
public function __construct($text)
{
Assertion::string($text);
Assertion::minLength($text, 1);
Assertion::maxLength($text, 1000);
$this->text = $text;
}
示例3: __construct
/**
* @param string $value
*/
public function __construct($value)
{
Assertion::string($value);
Assertion::minLength($value, 1);
Assertion::maxLength($value, 50);
$this->value = strtolower($value);
}
示例4: __construct
/**
* __construct()
*
* @param string $name Project name
*/
public function __construct($name)
{
Assertion::string($name);
Assertion::maxLength($name, 20, 'Project key exceeds max allowed chars');
Assertion::regex($name, '/^[a-z0-9\\-]*$/', 'Project key does not match expected format');
$this->name = $name;
$this->environments = new \SplObjectStorage();
$this->servers = new \SplObjectStorage();
$this->tasks = new \SplObjectStorage();
}
示例5: testValidMaxLength
public function testValidMaxLength()
{
Assertion::maxLength("foo", 10);
Assertion::maxLength("foo", 3);
Assertion::maxLength("", 0);
Assertion::maxLength("址址", 2);
}
示例6: referenceCode
/**
* Validate reference code:
* Length <= 20
* @param string $referenceCode
*/
public static function referenceCode($referenceCode)
{
Assert::maxLength($referenceCode, 20);
}
示例7: withCategory
/**
* @param string $category
*
* @throws \InvalidArgumentException
*
* @return static
*/
public function withCategory($category)
{
Assertion::string($category);
Assertion::maxLength($category, VideoInterface::CATEGORY_MAX_LENGTH);
$instance = clone $this;
$instance->category = $category;
return $instance;
}