本文整理匯總了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;
}