本文整理汇总了PHP中Assert\Assertion::range方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::range方法的具体用法?PHP Assertion::range怎么用?PHP Assertion::range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::range方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setRadius
/**
* Set the radius in meters.
*
* @param int $meters
*
* @return self
*/
public function setRadius($meters)
{
Assertion::integer($meters);
Assertion::range($meters, 1, 100000);
$this->radius = $meters;
return $this;
}
示例2: setLimit
/**
* Set the limit.
*
* @param int $limit
*
* @return self
*/
public function setLimit($limit)
{
Assertion::integer($limit);
Assertion::range($limit, 1, 50);
$this->limit = $limit;
return $this;
}
示例3: it_passes_values_and_constraints_to_exception
/**
* @test
*/
public function it_passes_values_and_constraints_to_exception()
{
try {
Assertion::range(0, 10, 20);
$this->fail('Exception expected');
} catch (AssertionFailedException $e) {
$this->assertEquals(0, $e->getValue());
$this->assertEquals(array('min' => 10, 'max' => 20), $e->getConstraints());
}
}
示例4: __construct
/**
* Deflate constructor.
*
* @param int $compression_level
*/
public function __construct($compression_level = -1)
{
Assertion::integer($compression_level, 'The compression level can be given as 0 for no compression up to 9 for maximum compression. If -1 given, the default compression level will be the default compression level of the zlib library.');
Assertion::range($compression_level, -1, 9, 'The compression level can be given as 0 for no compression up to 9 for maximum compression. If -1 given, the default compression level will be the default compression level of the zlib library.');
$this->compression_level = $compression_level;
}
示例5: inRange
public function inRange($value, $min, $max)
{
parent::range($value, $min, $max);
}
示例6: setStatus
/**
* @param int $status
*/
private function setStatus($status)
{
Assertion::integer($status);
Assertion::range($status, 0, 2);
$this->status = $status;
}
示例7: getDataPer30Minutes
/**
* @param integer $interval (1 or 2)
*
* @return History
*/
public function getDataPer30Minutes($interval = 1)
{
Assert::range($interval, 1, 2);
$response = $this->browser->get($this->createDataUrl(self::TYPE_HISTORICAL, array('h' => $interval)));
return $this->processHistoricalResponse($response);
}