/** * @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; }
/** * @param $text */ public function __construct($text) { Assertion::string($text); Assertion::minLength($text, 1); Assertion::maxLength($text, 1000); $this->text = $text; }
/** * @param string $value */ public function __construct($value) { Assertion::string($value); Assertion::minLength($value, 1); Assertion::maxLength($value, 50); $this->value = strtolower($value); }
/** * __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(); }
public function testValidMaxLength() { Assertion::maxLength("foo", 10); Assertion::maxLength("foo", 3); Assertion::maxLength("", 0); Assertion::maxLength("址址", 2); }
/** * Validate reference code: * Length <= 20 * @param string $referenceCode */ public static function referenceCode($referenceCode) { Assert::maxLength($referenceCode, 20); }
/** * @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; }