本文整理匯總了PHP中Assert\Assertion::true方法的典型用法代碼示例。如果您正苦於以下問題:PHP Assertion::true方法的具體用法?PHP Assertion::true怎麽用?PHP Assertion::true使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::true方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: checkerParameter
/**
* {@inheritdoc}
*/
public function checkerParameter(ClientInterface $client, array &$parameters)
{
if (false === strpos($parameters['response_type'], 'id_token')) {
return;
}
Assertion::true(array_key_exists('nonce', $parameters), 'The parameter "nonce" is mandatory.');
}
示例2: checkerParameter
/**
* {@inheritdoc}
*/
public function checkerParameter(ClientInterface $client, array &$parameters)
{
if (false === $this->state_parameter_enforced) {
return;
}
Assertion::true(array_key_exists('state', $parameters), 'The parameter "state" is mandatory.');
}
示例3: checkKey
/**
* @param JWKInterface $key
*/
private function checkKey(JWKInterface $key)
{
Assertion::eq($key->get('kty'), 'OKP', 'Wrong key type.');
Assertion::true($key->has('x'), 'The key parameter "x" is missing.');
Assertion::true($key->has('crv'), 'The key parameter "crv" is missing.');
Assertion::inArray($key->get('crv'), ['Ed25519'], 'Unsupported curve');
}
示例4: checkerParameter
/**
* {@inheritdoc}
*/
public function checkerParameter(ClientInterface $client, array &$parameters)
{
$scope = $this->getScopeManager()->checkScopePolicy($parameters['scope'], $client);
$available_scope = $this->getScopeManager()->getAvailableScopesForClient($client);
Assertion::true($this->getScopeManager()->areRequestScopesAvailable($scope, $available_scope), sprintf('An unsupported scope was requested. Available scopes for the client are %s', implode(',', $available_scope)));
$parameters['scope'] = $scope;
}
示例5: unserialize
/**
* @param \stdClass $obj
* @param array $context
* @return TwitterEvent
*/
public function unserialize($obj, array $context = [])
{
Assertion::true($this->canUnserialize($obj), 'object is not unserializable');
$createdAt = new \DateTimeImmutable($obj->created_at);
Assertion::eq(new \DateTimeZone('UTC'), $createdAt->getTimezone());
return TwitterEvent::create($obj->event, $this->userSerializer->unserialize($obj->source), isset($obj->target) ? $this->userSerializer->unserialize($obj->target) : null, isset($obj->target_object) ? $this->targetSerializer->unserialize($obj->target_object) : null, $createdAt);
}
示例6: fromString
/**
* Initializes and returns a coordinate object with the specified coordinate information in string format.
*
* Valid format:
* "latitude in degrees, longitude in degrees"
*
* Example:
* "51.3703748, 6.1724031"
*
* Please note that UTM and MGRS coordinates are not yet supported!
*
* @param $coordinate Coordinate information in string format
*
* @return static
*/
public static function fromString($coordinate)
{
Assertion::string($coordinate);
Assertion::true(substr_count($coordinate, ',') === 1);
$coordinate = explode(',', $coordinate);
return new static((double) $coordinate[0], (double) $coordinate[1]);
}
示例7: checkerParameter
/**
* {@inheritdoc}
*/
public function checkerParameter(ClientInterface $client, array &$parameters)
{
if (false === array_key_exists('response_mode', $parameters)) {
return;
}
Assertion::true($this->isResponseModeParameterInAuthorizationRequestAllowed(), 'The parameter "response_mode" is not allowed.');
}
示例8: addOptions
private function addOptions(DOMDocument $document, DOMNode $node, array $options, array $selectedValues)
{
foreach ($options as $value => $label) {
if (is_int($value)) {
$value = (string) $value;
} else {
Assertion::string($value);
}
Assertion::true(is_string($label) || is_array($label));
if (is_array($label)) {
$optgroup = $document->createElement('optgroup');
$this->addAttributes($optgroup, ['label' => $value]);
$this->addOptions($document, $optgroup, $label, $selectedValues);
$node->appendChild($optgroup);
continue;
}
$option = $document->createElement('option');
$option->appendChild($document->createTextNode($label));
$htmlAttributes = ['value' => $value];
if (in_array($value, $selectedValues)) {
$htmlAttributes['selected'] = 'selected';
}
$this->addAttributes($option, $htmlAttributes);
$node->appendChild($option);
}
}
示例9: unserialize
/**
* @param \stdClass $obj
* @param array $context
* @return \Twitter\Object\Tweet
*/
public function unserialize($obj, array $context = [])
{
Assertion::true($this->canUnserialize($obj), 'object is not unserializable');
$createdAt = new \DateTimeImmutable($obj->created_at);
Assertion::eq(new \DateTimeZone('UTC'), $createdAt->getTimezone());
return Tweet::create(TwitterMessageId::create($obj->id), $this->userSerializer->unserialize($obj->user), $obj->text, $obj->lang, $createdAt, $obj->entities ? $this->twitterEntitiesSerializer->unserialize($obj->entities) : TwitterEntities::create(), $obj->coordinates ? $this->coordinatesSerializer->unserialize($obj->coordinates) : null, $obj->place ? $this->placeSerializer->unserialize($obj->place) : null, $obj->in_reply_to_status_id, $obj->in_reply_to_user_id, $obj->in_reply_to_screen_name, $obj->retweeted, $obj->retweet_count, $obj->favorited, $obj->favorite_count, $obj->truncated, $obj->source, isset($obj->retweeted_status) ? $this->unserialize($obj->retweeted_status) : null);
}
示例10: checkPKCEInput
/**
* {@inheritdoc}
*/
public function checkPKCEInput($code_challenge_method, $code_challenge, $code_verifier)
{
Assertion::true($this->hasPKCEMethod($code_challenge_method), sprintf('Unsupported code challenge method "%s".', $code_challenge_method));
$method = $this->getPKCEMethod($code_challenge_method);
Assertion::notNull($code_verifier, 'The parameter "code_verifier" is required.');
Assertion::true($method->isChallengeVerified($code_verifier, $code_challenge), 'Invalid parameter "code_verifier".');
}
示例11: checkerParameter
/**
* {@inheritdoc}
*/
public function checkerParameter(ClientInterface $client, array &$parameters)
{
if (!array_key_exists('display', $parameters)) {
return;
}
Assertion::true(in_array($parameters['display'], $this->getAllowedDisplayValues()), sprintf('Invalid parameter "display". Allowed values are %s', json_encode($this->getAllowedDisplayValues())));
}
示例12: getKey
/**
* @param int $index
*
* @return \Jose\Object\JWKInterface
*/
public function getKey($index)
{
Assertion::integer($index, 'The index must be a positive integer.');
Assertion::greaterOrEqualThan($index, 0, 'The index must be a positive integer.');
Assertion::true($this->hasKey($index), 'Undefined index.');
return $this->getKeys()[$index];
}
示例13: serialize
/**
* @param TwitterSerializable $object
* @return \stdClass
*/
public function serialize(TwitterSerializable $object)
{
Assertion::true($this->canSerialize($object), 'object must be an instance of TwitterEventTarget');
if ($object instanceof Tweet) {
return $this->tweetSerializer->serialize($object);
}
throw new \BadMethodCallException('Not Implemented');
}
示例14: encrypt
/**
* {@inheritdoc}
*/
public function encrypt($payload, array $encryption_protected_headers, Object\JWKInterface $encryption_key)
{
Assertion::true($this->isEncryptionSupportEnabled(), 'The encryption support is not enabled');
$jwe = Factory\JWEFactory::createJWE($payload, $encryption_protected_headers);
$jwe = $jwe->addRecipientInformation($encryption_key);
$this->encrypter->encrypt($jwe);
return $jwe->toCompactJSON(0);
}
示例15: checkerParameter
/**
* {@inheritdoc}
*/
public function checkerParameter(ClientInterface $client, array &$parameters)
{
if (!array_key_exists('prompt', $parameters)) {
return;
}
Assertion::true(empty(array_diff($parameters['prompt'], $this->getAllowedPromptValues())), sprintf('Invalid parameter "prompt". Allowed values are %s', json_encode($this->getAllowedPromptValues())));
Assertion::false(in_array('none', $parameters['prompt']) && 1 !== count($parameters['prompt']), 'Invalid parameter "prompt". Prompt value "none" must be used alone.');
}