本文整理汇总了PHP中Webmozart\Assert\Assert::nullOrInteger方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::nullOrInteger方法的具体用法?PHP Assert::nullOrInteger怎么用?PHP Assert::nullOrInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Assert\Assert
的用法示例。
在下文中一共展示了Assert::nullOrInteger方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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;
}
示例2: __construct
/**
* Creates a new parameter.
*
* @param string $name The parameter name.
* @param int $flags A bitwise combination of the flag constants
* in this class.
* @param mixed $defaultValue The parameter's default value.
*/
public function __construct($name, $flags = self::OPTIONAL, $defaultValue = null)
{
Assert::stringNotEmpty($name, 'The parameter name must be a non-empty string. Got: %s');
Assert::startsWithLetter($name, 'The parameter name must start with a letter. Got: %s');
Assert::nullOrInteger($flags, 'The parameter "$flags" must be an integer or null. Got: %s');
if ($flags & self::REQUIRED && null !== $defaultValue) {
throw new RuntimeException('Required parameters must not have default values.');
}
$this->name = $name;
$this->flags = $flags;
$this->defaultValue = $defaultValue;
}
示例3: setSemester
/**
* Set semester
*
* @param integer $semester
* @return User
*/
public function setSemester($semester)
{
Assert::nullOrInteger($semester);
$this->semester = $semester;
return $this;
}