Пример #1
0
 /**
  * @param array $countryCodes
  *
  * @throws \InvalidArgumentException
  *
  * @return static
  */
 public function withCountryCodes(array $countryCodes)
 {
     Assertion::allString($countryCodes);
     Assertion::allNotBlank($countryCodes);
     $instance = clone $this;
     $instance->countryCodes = $countryCodes;
     return $instance;
 }
 /**
  * @param \OAuth2\Client\ClientInterface $client
  * @param array                          $registration_parameters
  */
 private function checkResponseTypes(ClientInterface $client, array $registration_parameters)
 {
     Assertion::isArray($registration_parameters['response_types'], 'The parameter "response_types" must be an array of strings.');
     Assertion::allString($registration_parameters['response_types'], 'The parameter "grant_types" must be an array of strings.');
     foreach ($registration_parameters['response_types'] as $response_type) {
         $types = $this->getResponseTypeManager()->getResponseTypes($response_type);
         if (!in_array($response_type, $client->get('response_types'))) {
             $response_types = $client->get('response_types');
             $response_types[] = $response_type;
             $client->set('response_types', $response_types);
         }
         foreach ($types as $type) {
             $associated_grant_types = $type->getAssociatedGrantTypes();
             $diff = array_diff($associated_grant_types, $registration_parameters['grant_types']);
             Assertion::true(empty($diff), sprintf('The response type "%s" is associated with the grant types "%s" but this response type is missing.', $type->getResponseType(), json_encode($diff)));
             $client->set('grant_types', array_unique(array_merge($client->get('grant_types'), $associated_grant_types)));
         }
     }
 }
Пример #3
0
 public function recordCustomEvent($name, array $attributes)
 {
     Assertion::string($name);
     Assertion::notBlank($name);
     Assertion::allString(array_keys($attributes));
     Assertion::allScalar(array_values($attributes));
     $this->handle('newrelic_record_custom_event', [$name, $attributes]);
 }
 /**
  * {@inheritdoc}
  */
 public function enableRequestObjectSupport(JWTLoaderInterface $jwt_loader, array $mandatory_claims = [])
 {
     Assertion::allString($mandatory_claims, 'The mandatory claims array should contain only claims.');
     $this->setJWTLoader($jwt_loader);
     $this->request_object_allowed = true;
     $this->mandatory_claims = $mandatory_claims;
 }
 /**
  * @param string   $name
  * @param string[] $jwksets
  * @param bool     $is_public
  *
  * @return array
  */
 private static function getJWKSetsConfiguration($name, array $jwksets, $is_public = true)
 {
     self::checkParameters($name, $is_public);
     Assertion::isArray($jwksets);
     Assertion::allString($jwksets);
     Assertion::allNotEmpty($jwksets);
     return [self::BUNDLE_ALIAS => ['key_sets' => [$name => ['jwksets' => ['is_public' => $is_public, 'id' => $jwksets]]]]];
 }
Пример #6
0
 /**
  * @param array $taskDefinition
  * @return ProcessData
  */
 private function createProcessDataTaskFromDefinition(array $taskDefinition)
 {
     Assertion::keyExists($taskDefinition, "target");
     Assertion::notEmpty($taskDefinition["target"]);
     Assertion::string($taskDefinition["target"]);
     Assertion::keyExists($taskDefinition, "allowed_types");
     Assertion::isArray($taskDefinition["allowed_types"]);
     Assertion::allString($taskDefinition["allowed_types"]);
     $preferredType = isset($taskDefinition["preferred_type"]) ? $taskDefinition["preferred_type"] : null;
     $metadata = isset($taskDefinition['metadata']) ? $taskDefinition['metadata'] : array();
     return ProcessData::address($taskDefinition["target"], $taskDefinition["allowed_types"], $preferredType, $metadata);
 }
Пример #7
0
 /**
  * @param array $cookies
  */
 public function __construct(array $cookies = [])
 {
     Assertion::allString(array_keys($cookies), 'CookieJar must be instantiated with an associative array');
     $this->cookies = $cookies;
 }
Пример #8
0
 /**
  * @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;
 }