本文整理汇总了PHP中Assert\Assertion::isArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::isArray方法的具体用法?PHP Assertion::isArray怎么用?PHP Assertion::isArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::isArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guardRequiredState
protected function guardRequiredState()
{
parent::guardRequiredState();
Assertion::regex($this->projection_type, '#^([a-z][a-z_-]+(?<!_-)\\.){2}[a-z][a-z_]+(?<!_)::projection\\.[a-z][a-z_]+(?<!_)$#');
Assertion::isArray($this->data);
Assertion::regex($this->projection_identifier, '/[\\w\\.\\-_]{1,128}\\-\\w{8}\\-\\w{4}\\-\\w{4}\\-\\w{4}\\-\\w{12}\\-\\w{2}_\\w{2}\\-\\d+/');
}
示例2: authenticate
/**
* {@inheritdoc}
*/
public function authenticate($subject, Caller $caller)
{
Assertion::isArray($subject);
Assertion::choicesNotEmpty($subject, ['password']);
Assertion::isInstanceOf($caller, 'Guardian\\User\\Caller', sprintf('The caller was expected to be an instance of "%s"', 'Indigo\\Guardian\\Caller\\User'));
return $this->hasher->verify($subject['password'], $caller->getPassword());
}
示例3: 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();
}
示例4: validate
private function validate()
{
Assertion::keyExists($this->options, 'packages');
Assertion::isArray($this->options['packages']);
Assertion::keyExists($this->options, 'rooms');
Assertion::isArray($this->options['rooms']);
}
示例5: deserialize
public static function deserialize($data)
{
Assertion::isArray($data);
$entities = array_map(function ($entity) {
return Entity::deserialize($entity);
}, $data);
return new self($entities);
}
示例6: __construct
/**
* Create a new value object
* @param array $value
*/
public function __construct($value)
{
Assertion::isArray($value);
foreach ($value as $object) {
Assertion::implementsInterface($object, EventInterface::class);
}
$this->value = SplFixedArray::fromArray($value);
}
示例7: extractWithMetadata
private function extractWithMetadata($entity, Entity $metadata) : array
{
if ($entity instanceof ProxyInterface) {
$entity = $entity->__getRealEntity();
}
Assertion::isInstanceOf($entity, $metadata->getClassName());
$data = [];
$reflectionClass = new ReflectionClass($entity);
foreach ($metadata->getFields() as $fieldMetadata) {
if ($fieldMetadata->isReadOnly()) {
continue;
}
$fieldName = $fieldMetadata->getFieldName();
try {
$type = $fieldMetadata->getType();
$value = $this->getProperty($reflectionClass, $entity, $fieldMetadata->getPropertyName());
if (!$fieldMetadata->isRepeatable()) {
$data[$fieldName] = $type->toFileMakerValue($value);
continue;
}
Assertion::isArray($value);
$index = 0;
foreach ($value as $individualValue) {
$data[sprintf('%s(%d)', $fieldName, ++$index)] = $type->toFileMakerValue($individualValue);
}
} catch (Exception $e) {
throw ExtractionException::fromInvalidField($metadata, $fieldMetadata, $e);
}
}
foreach ($metadata->getEmbeddables() as $embeddableMetadata) {
$prefix = $embeddableMetadata->getFieldNamePrefix();
$embeddableData = $this->extractWithMetadata($this->getProperty($reflectionClass, $entity, $embeddableMetadata->getPropertyName()), $embeddableMetadata->getMetadata());
foreach ($embeddableData as $key => $value) {
$data[$prefix . $key] = $value;
}
}
$toOne = array_filter($metadata->getManyToOne(), function (ManyToOne $manyToOneMetadata) {
return !$manyToOneMetadata->isReadOnly();
}) + array_filter($metadata->getOneToOne(), function (OneToOne $oneToOneMetadata) {
return $oneToOneMetadata->isOwningSide() && !$oneToOneMetadata->isReadOnly();
});
foreach ($toOne as $relationMetadata) {
$relation = $this->getProperty($reflectionClass, $entity, $relationMetadata->getPropertyName());
if (null === $relation) {
$data[$relationMetadata->getFieldName()] = null;
continue;
}
if ($relation instanceof ProxyInterface) {
Assertion::isInstanceOf($relation->__getRealEntity(), $relationMetadata->getTargetEntity());
$relationId = $relation->__getRelationId();
} else {
Assertion::isInstanceOf($relation, $relationMetadata->getTargetEntity());
$relationId = $this->getProperty(new ReflectionClass($relation), $relation, $relationMetadata->getTargetPropertyName());
}
$data[$relationMetadata->getFieldName()] = $relationId;
}
return $data;
}
示例8: check
/**
* {@inheritdoc}
*/
public function check(ClientInterface $client, array $registration_parameters)
{
if (!array_key_exists('request_uris', $registration_parameters)) {
return;
}
Assertion::isArray($registration_parameters['request_uris'], 'The parameter "request_uris" must be a list of URI.');
Assertion::allUrl($registration_parameters['request_uris'], 'The parameter "request_uris" must be a list of URI.');
$client->set('request_uris', $registration_parameters['request_uris']);
}
示例9: __construct
/**
* Create a new immutable Body instance
*
* @param string $route
* @param string $signature
* @param array $data
* @return void
*/
public function __construct($route, $signature, $data)
{
Assertion::url($route);
Assertion::string($signature);
Assertion::isArray($data);
$this->route = $route;
$this->signature = $signature;
$this->data = $data;
}
示例10: loadFromProvisioningUri
/**
* @param string $uri
*
* @throws \InvalidArgumentException
*
* @return \OTPHP\TOTP|\OTPHP\HOTP
*/
public static function loadFromProvisioningUri($uri)
{
$parsed_url = parse_url($uri);
Assertion::isArray($parsed_url, 'Not a valid OTP provisioning URI');
self::checkData($parsed_url);
$otp = self::createOTP($parsed_url);
self::populateOTP($otp, $parsed_url);
return $otp;
}
示例11: reconstituteFromArray
/**
* @param array $taskData
* @return static
*/
public static function reconstituteFromArray(array $taskData)
{
Assertion::keyExists($taskData, 'target');
Assertion::keyExists($taskData, 'allowed_types');
Assertion::keyExists($taskData, 'preferred_type');
Assertion::keyExists($taskData, 'metadata');
Assertion::isArray($taskData['allowed_types']);
return new self($taskData['target'], $taskData['allowed_types'], $taskData['preferred_type'], $taskData['metadata']);
}
示例12: guardRequiredState
protected function guardRequiredState()
{
parent::guardRequiredState();
Assertion::string($this->parent_attribute_name);
Assertion::string($this->embedded_entity_type);
Assertion::uuid($this->embedded_entity_identifier);
Assertion::isArray($this->embedded_entity_events);
Assertion::isArray($this->data);
}
示例13: checkHeader
/**
* {@inheritdoc}
*/
public function checkHeader(array $protected_headers, array $headers, array $checked_claims)
{
if (!array_key_exists('crit', $protected_headers)) {
return;
}
Assertion::isArray($protected_headers['crit'], 'The parameter "crit" must be a list.');
$diff = array_diff($protected_headers['crit'], $checked_claims);
Assertion::true(empty($diff), sprintf('One or more claims are marked as critical, but they are missing or have not been checked (%s).', json_encode(array_values($diff))));
}
示例14: unbind
public function unbind($value) : Data
{
Assertion::isArray($value);
$data = Data::none();
foreach ($value as $index => $individualValue) {
$data = $data->merge($this->wrappedMapping->withPrefixAndRelativeKey($this->key, (string) $index)->unbind($individualValue));
}
return $data;
}
示例15: guardRequiredState
protected function guardRequiredState()
{
parent::guardRequiredState();
Assertion::isArray($this->data);
$mandatory_attribute_names = ['identifier', 'uuid', 'language', 'version', 'workflow_state'];
foreach ($mandatory_attribute_names as $attribute_name) {
Assertion::keyExists($this->data, $attribute_name, 'mandatory');
}
}