本文整理汇总了PHP中Assert\Assertion::keyExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::keyExists方法的具体用法?PHP Assertion::keyExists怎么用?PHP Assertion::keyExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::keyExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getKeys
/**
* @return \Jose\Object\JWKInterface[]
*/
public function getKeys()
{
$content = json_decode($this->getContent(), true);
Assertion::isArray($content, 'Invalid content.');
Assertion::keyExists($content, 'keys', 'Invalid content.');
return (new JWKSet($content))->getKeys();
}
示例2: checkerParameter
/**
* {@inheritdoc}
*/
public function checkerParameter(ClientInterface $client, array &$parameters)
{
/*
* @see http://tools.ietf.org/html/rfc6749#section-3.1.1
*/
Assertion::keyExists($parameters, 'response_type', 'The parameter "response_type" is mandatory.');
}
示例3: fromArray
/**
* @param array $array
* @return Issuer
*/
public static function fromArray(array $array)
{
Guard::keyExists($array, 'id');
Guard::keyExists($array, 'name');
Guard::keyExists($array, 'list_type');
return new Issuer(SwiftBic::fromString($array['id']), Name::fromString($array['name']), ListType::fromString($array['list_type']));
}
示例4: reconstituteFromArray
/**
* @param array $taskData
* @return static
*/
public static function reconstituteFromArray(array $taskData)
{
Assertion::keyExists($taskData, 'target_node_name');
Assertion::keyExists($taskData, 'process_definition');
Assertion::keyExists($taskData, 'sync_log_messages');
return new self(NodeName::fromString($taskData['target_node_name']), $taskData['process_definition'], (bool) $taskData['sync_log_messages']);
}
示例5: create
/**
* @param Request $request
*
* @return JsonResponse
*
* @throws \Assert\AssertionFailedException
* @throws InvalidMobileApiException
* @throws BlankAliasApiException
* @throws NoTopicsApiException
* @throws InsufficientBalanceApiException
* @throws ExistentMobileApiException
*/
protected function create(Request $request)
{
/** @var UsernamePasswordToken $token */
$token = $this->tokenStorage->getToken();
$uniqueness = $token->getUsername();
$data = $request->request->all();
foreach (array('mobile', 'alias', 'topics') as $key) {
Assertion::keyExists($data, $key);
}
try {
$this->createSubscriptionApiWorker->create($data['mobile'], $uniqueness, $data['alias'], $data['topics'], $data['resellPackage']);
} catch (InvalidMobileApiException $e) {
return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.INVALID_MOBILE'), 400);
} catch (BlankAliasApiException $e) {
return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.BLANK_ALIAS'), 400);
} catch (ExistentMobileApiException $e) {
return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.EXISTENT_MOBILE'), 400);
} catch (NoTopicsApiException $e) {
return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.NO_TOPICS'), 400);
} catch (NoResellPackageApiException $e) {
return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.NO_RESELL_PACKAGE'), 400);
} catch (TrialNotAcceptedApiException $e) {
return new JsonResponse(array('code' => 'INFO_SMS.SUBSCRIPTION.TRIAL_NOT_ACCEPTED'), 400);
} catch (InsufficientBalanceApiException $e) {
return new JsonResponse(array('code' => 'INFO_SMS.PROFILE.INSUFFICIENT_BALANCE'), 400);
}
return new JsonResponse();
}
示例6: deserialize
/**
* @param array $serializedObject
*
* @return mixed
*
* @throws SerializationException
*/
public function deserialize(array $serializedObject)
{
Assert::keyExists($serializedObject, 'type', "Key 'type' should be set.");
Assert::keyExists($serializedObject, 'payload', "Key 'payload' should be set.");
// TODO implement TypeDenormalizer
return $this->denormalizer->denormalize($serializedObject['payload'], $serializedObject['type'], 'json');
}
示例7: validate
private function validate()
{
Assertion::keyExists($this->options, 'packages');
Assertion::isArray($this->options['packages']);
Assertion::keyExists($this->options, 'rooms');
Assertion::isArray($this->options['rooms']);
}
示例8: fromArray
/**
* Creates a new domain message from given array
*
* @param array $messageData
* @return static
*/
public static function fromArray(array $messageData)
{
Assertion::keyExists($messageData, 'uuid');
Assertion::keyExists($messageData, 'message_name');
Assertion::string($messageData['message_name'], 'message name needs to be string');
Assertion::notEmpty($messageData['message_name'], 'message name must not be empty');
Assertion::keyExists($messageData, 'version');
Assertion::integer($messageData['version'], 'version needs to be an integer');
Assertion::keyExists($messageData, 'payload');
Assertion::isArray($messageData['payload'], 'payload needs to be an array');
Assertion::keyExists($messageData, 'metadata');
Assertion::keyExists($messageData, 'created_at');
Assertion::isArray($messageData['metadata'], 'metadata needs to be an array');
$messageRef = new \ReflectionClass(get_called_class());
/** @var $message DomainMessage */
$message = $messageRef->newInstanceWithoutConstructor();
$message->uuid = Uuid::fromString($messageData['uuid']);
$message->messageName = $messageData['message_name'];
$message->version = $messageData['version'];
$message->setPayload($messageData['payload']);
$message->metadata = $messageData['metadata'];
if (!$messageData['created_at'] instanceof \DateTimeInterface) {
$messageData['created_at'] = \DateTimeImmutable::createFromFormat($message->dateTimeFormat, $messageData['created_at'], new \DateTimeZone('UTC'));
}
$message->createdAt = $messageData['created_at'];
return $message;
}
示例9: assertConfig
private function assertConfig(array $config)
{
Assertion::keyExists($config, "dbname");
Assertion::string($config['dbname']);
Assertion::keyExists($config, "driver");
Assertion::inArray($config["driver"], $this->supportedDrivers);
}
示例10: fromArray
public static function fromArray(array $array)
{
Ensure::keyExists($array, 'title');
Ensure::keyExists($array, 'repositoryName');
Ensure::keyExists($array, 'url');
Ensure::keyExists($array, 'loneliness');
return self::create(Title::fromString($array['title']), RepositoryName::fromString($array['repositoryName']), Url::fromString($array['url']), Loneliness::fromInteger($array['loneliness']));
}
示例11: fromJsonDecodedData
/**
* @param array $jsonDecodedData
* @return Payload
*/
public static function fromJsonDecodedData(array $jsonDecodedData)
{
Assertion::keyExists($jsonDecodedData, 'typeClass');
Assertion::keyExists($jsonDecodedData, 'data');
Assertion::notEmpty($jsonDecodedData['typeClass']);
Assertion::string($jsonDecodedData['typeClass']);
return new static($jsonDecodedData['typeClass'], $jsonDecodedData['data']);
}
示例12: fromPersistedState
public static function fromPersistedState(array $state)
{
Assertion::keyExists($state, 'account_id');
Assertion::keyExists($state, 'email');
Assertion::keyExists($state, 'password');
Assertion::keyExists($state, 'salt');
return new AccountCredentials(new AccountId($state['account_id']), new Credentials(new EmailAddress($state['email']), $state['password'], $state['salt']));
}
示例13: fromArray
/**
* @param $array
*
* @return Notification
*/
public static function fromArray($array)
{
Ensure::keyExists($array, 'repositoryName');
Ensure::keyExists($array, 'title');
Ensure::keyExists($array, 'url');
Ensure::keyExists($array, 'eventDateTime');
return new self(RepositoryName::fromString($array['repositoryName']), Title::fromString($array['title']), Url::fromString($array['url']), new DateTimeImmutable($array['eventDateTime']));
}
示例14: __construct
/**
* Create a new Currency
*
* @param string $name
*/
private function __construct($name)
{
if (!isset(self::$currencies)) {
self::$currencies = (require __DIR__ . '/currencies.php');
}
Assertion::keyExists(self::$currencies, $name);
$this->name = $name;
}
示例15: __invoke
public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
{
$data = $request->getParsedBody();
Assertion::keyExists($data, 'origin');
Assertion::keyExists($data, 'destination');
$trackingId = $this->bookingService->bookNewCargo($data['origin'], $data['destination']);
return new JsonResponse(['trackingId' => $trackingId]);
}