本文整理汇总了PHP中Assert\Assertion::lessOrEqualThan方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::lessOrEqualThan方法的具体用法?PHP Assertion::lessOrEqualThan怎么用?PHP Assertion::lessOrEqualThan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::lessOrEqualThan方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkClaim
/**
* {@inheritdoc}
*/
public function checkClaim(JWTInterface $jwt)
{
if (!$jwt->hasClaim('iat')) {
return [];
}
$iat = (int) $jwt->getClaim('iat');
Assertion::lessOrEqualThan($iat, time(), 'The JWT is issued in the future.');
return ['iat'];
}
示例2: checkClaim
/**
* {@inheritdoc}
*/
public function checkClaim(JWTInterface $jwt)
{
if (!$jwt->hasClaim('nbf')) {
return [];
}
$nbf = (int) $jwt->getClaim('nbf');
Assertion::lessOrEqualThan($nbf, time(), 'The JWT can not be used yet.');
return ['nbf'];
}
示例3: __construct
private function __construct(Coords $startPoint, Coords $endPoint, $hits = 0)
{
Assertion::integer($hits);
Assertion::greaterOrEqualThan($hits, 0);
$size = $startPoint->distance($endPoint) + 1;
Assertion::greaterOrEqualThan($size, static::MINIMUM_SIZE);
Assertion::lessOrEqualThan($hits, $size);
$this->startPoint = $startPoint;
$this->endPoint = $endPoint;
$this->hits = $hits;
}
示例4: __construct
/**
* A value object that contains a geographical coordinate.
*
* @param $latitude
* @param $longitude
*/
public function __construct($latitude, $longitude)
{
Assertion::true(is_int($latitude) || is_float($latitude));
Assertion::true(is_int($longitude) || is_float($longitude));
Assertion::greaterOrEqualThan($latitude, -90.0);
Assertion::lessOrEqualThan($latitude, 90.0);
Assertion::greaterOrEqualThan($longitude, -180.0);
Assertion::lessOrEqualThan($longitude, 180.0);
$this->latitude = $latitude;
$this->longitude = $longitude;
}
示例5: testLessOrEqualThanThrowsException
/**
* @dataProvider invalidLessOrEqualProvider
*/
public function testLessOrEqualThanThrowsException($value, $limit)
{
$this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INVALID_LESS_OR_EQUAL);
Assertion::lessOrEqualThan($value, $limit);
}
示例6: __construct
/**
* @param array[] $urls
*
* @throws \InvalidArgumentException
*/
public function __construct(array $urls)
{
Assertion::allIsInstanceOf($urls, UrlInterface::class);
Assertion::lessOrEqualThan(count($urls), UrlSetInterface::URL_MAX_COUNT);
$this->urls = $urls;
}
示例7: performRequest
/**
* Performs a request to the symfony application and returns the response.
*
* @param string $method
* @param string $uri
* @param mixed[] $parameters
* @param bool $expectSuccess
* @param string[] $headers
* @param mixed[] $files
* @param int $expectedStatus
* @param bool $toJson
* @param string $apiKey
* @param bool $disableAssertions
*
* @throws \Exception If the json decode did not work
*
* @return string[]
*/
protected function performRequest($method, $uri, array $parameters = [], $expectSuccess = true, array $headers = [], array $files = [], $expectedStatus = 200, $toJson = true, $apiKey = null, $disableAssertions = false)
{
if (null !== $apiKey || null !== AppContext::$apiKey) {
$headers[ApiKeyAuthenticator::API_KEY_HEADER] = $apiKey ?: AppContext::$apiKey;
}
$headers = array_combine(array_map(function ($headerName) {
return sprintf('HTTP_%s', $headerName);
}, array_keys($headers)), array_values($headers));
/** @var \Symfony\Bundle\FrameworkBundle\Client $client */
$client = $this->getContainer()->get('test.client');
$client->enableProfiler();
$client->request($method, $uri, $parameters, $files, $headers);
$response = $client->getResponse();
if (!$disableAssertions) {
$status = $response->getStatusCode();
if ($expectSuccess) {
Assertion::greaterOrEqualThan($status, 200);
Assertion::lessOrEqualThan($status, 399);
} else {
Assertion::greaterOrEqualThan($status, 400);
Assertion::lessOrEqualThan($status, 599);
}
Assertion::same($expectedStatus, $status);
}
$this->recentClient = $client;
if ($toJson) {
$content = $response->getContent();
if (empty($content)) {
$raw = null;
} else {
$raw = json_decode($content, true);
Assertion::same(JSON_ERROR_NONE, json_last_error());
}
return $raw;
}
return $response;
}
示例8: withTags
/**
* @param TagInterface[] $tags
*
* @throws \InvalidArgumentException
*
* @return static
*/
public function withTags(array $tags)
{
Assertion::allIsInstanceOf($tags, TagInterface::class);
Assertion::lessOrEqualThan(count($tags), VideoInterface::TAG_MAX_COUNT);
$instance = clone $this;
$instance->tags = $tags;
return $instance;
}
示例9: withImages
/**
* @param ImageInterface[] $images
*
* @throws \InvalidArgumentException
*
* @return static
*/
public function withImages(array $images)
{
Assertion::allIsInstanceOf($images, ImageInterface::class);
Assertion::lessOrEqualThan(count($this->images), UrlInterface::IMAGE_MAX_COUNT);
$instance = clone $this;
$instance->images = $images;
return $instance;
}
示例10: withStockTickers
/**
* @param array $stockTickers
*
* @throws \InvalidArgumentException
*
* @return static
*/
public function withStockTickers(array $stockTickers)
{
Assertion::allString($stockTickers);
Assertion::allNotBlank($stockTickers);
Assertion::lessOrEqualThan(count($stockTickers), NewsInterface::STOCK_TICKERS_MAX_COUNT);
$instance = clone $this;
$instance->stockTickers = $stockTickers;
return $instance;
}