当前位置: 首页>>代码示例>>PHP>>正文


PHP Assertion::notNull方法代码示例

本文整理汇总了PHP中Assert\Assertion::notNull方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::notNull方法的具体用法?PHP Assertion::notNull怎么用?PHP Assertion::notNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Assert\Assertion的用法示例。


在下文中一共展示了Assertion::notNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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".');
 }
开发者ID:spomky-labs,项目名称:oauth2-server-library,代码行数:10,代码来源:PKCEMethodManager.php

示例2: __construct

 /**
  * SimpleStringAccessTokenManager constructor.
  *
  * @param string                                                      $class
  * @param \Doctrine\Common\Persistence\ManagerRegistry                $manager_registry
  * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
  */
 public function __construct($class, ManagerRegistry $manager_registry, EventDispatcherInterface $event_dispatcher)
 {
     $this->class = $class;
     $this->event_dispatcher = $event_dispatcher;
     $this->entity_manager = $manager_registry->getManagerForClass($class);
     Assertion::notNull($this->entity_manager, sprintf('Unable to find the entity manager for the class "%s"', $class));
     $this->entity_repository = $this->entity_manager->getRepository($class);
 }
开发者ID:spomky-labs,项目名称:oauth2-server-bundle,代码行数:15,代码来源:SimpleStringAccessTokenManager.php

示例3: applyLetterGuessedCorrectly

 /**
  * @param LetterGuessedCorrectly $event
  */
 public function applyLetterGuessedCorrectly(LetterGuessedCorrectly $event)
 {
     $readModel = $this->repository->findBy(["gameId" => $event->getGameId()]);
     Assertion::notNull($readModel, "Readmodel doesn't hold an object");
     $lastResult = end($readModel);
     $readModel = $lastResult->setLetterCorrectlyGuessed($event->getLetters());
     $this->repository->save($readModel);
 }
开发者ID:lenmen,项目名称:hangman_leon,代码行数:11,代码来源:GameStaticsProjector.php

示例4: __construct

 /**
  * @param mixed $data
  * @throws \InvalidArgumentException
  */
 public function __construct($data)
 {
     Assertion::notNull($data, 'Data must not be null');
     if (is_object($data)) {
         throw new \InvalidArgumentException('Complex data must only be structured as array. An object is not allowed');
     }
     $this->data = $data;
 }
开发者ID:gingerwfms,项目名称:ginger-workflow-engine,代码行数:12,代码来源:Item.php

示例5: theRoleAndAdminFixturesShouldBeApplied

 /**
  * @Then the role and admin fixtures should be applied
  */
 public function theRoleAndAdminFixturesShouldBeApplied()
 {
     $em = $this->getEntityManager();
     $roleRepository = $em->getRepository('Account:Role');
     $userRepository = $em->getRepository('Account:User');
     Assertion::notNull($roleRepository->findOneBy(['role' => 'ROLE_USER']));
     Assertion::notNull($roleRepository->findOneBy(['role' => 'ROLE_ADMIN']));
     Assertion::notNull($userRepository->findOneBy(['username' => 'admin']));
 }
开发者ID:thomasmodeneis,项目名称:Sententiaregum,代码行数:12,代码来源:DoctrineFixtureContext.php

示例6: addProductToBasketAction

 /**
  * @param string $basketId
  *
  * @return Response
  */
 public function addProductToBasketAction(Request $request, $basketId)
 {
     $basketId = new BasketId($basketId);
     $productToAdd = $request->request->get('productId');
     $productName = $request->request->get('productName');
     Assert::notNull($productName);
     $command = new AddProductToBasket($basketId, $productToAdd, $productName);
     $this->commandBus->dispatch($command);
     return new Response();
 }
开发者ID:loicbourg,项目名称:broadway-demo,代码行数:15,代码来源:BasketController.php

示例7: __construct

 /**
  * @param string $result
  * @param Coords $target
  * @param Coords $startPoint
  * @param Coords $endPoint
  */
 private function __construct($result, Coords $target, Coords $startPoint = null, Coords $endPoint = null)
 {
     Assertion::choice($result, [static::HIT, static::MISS, static::SANK, static::WIN]);
     if (in_array($result, [static::SANK, static::WIN])) {
         Assertion::notNull($startPoint);
         Assertion::notNull($endPoint);
     }
     $this->result = $result;
     $this->startPoint = $startPoint;
     $this->endPoint = $endPoint;
     $this->target = $target;
 }
开发者ID:WeCamp,项目名称:flyingliquourice,代码行数:18,代码来源:FireResult.php

示例8: __construct

 /**
  * @param $anAgentDescriptionOrRole
  * @param ActionDescription $anActionDescriptionOrNull
  */
 private function __construct($anAgentDescriptionOrRole, ActionDescription $anActionDescriptionOrNull = null)
 {
     if ($anAgentDescriptionOrRole instanceof AgentDescription) {
         $this->agentDescription = $anAgentDescriptionOrRole;
     } else {
         if ($anAgentDescriptionOrRole instanceof RoleDescription) {
             Assertion::notNull($anActionDescriptionOrNull, 'ActionDescription is required when ProcessSep is setup with a RoleDescription.');
             $this->role = $anAgentDescriptionOrRole;
             $this->actionDescription = $anActionDescriptionOrNull;
         }
     }
 }
开发者ID:gingerwfms,项目名称:ginger-core,代码行数:16,代码来源:ProcessStep.php

示例9: getEncodedPayload

 /**
  * {@inheritdoc}
  */
 public function getEncodedPayload(SignatureInterface $signature)
 {
     if (true === $this->isPayloadDetached()) {
         return;
     }
     if (null !== $this->encoded_payload) {
         return $this->encoded_payload;
     }
     $payload = $this->getPayload();
     if (!is_string($payload)) {
         $payload = json_encode($payload);
     }
     Assertion::notNull($payload, 'Unsupported payload.');
     return $this->isPayloadEncoded($signature) ? Base64Url::encode($payload) : $payload;
 }
开发者ID:spomky-labs,项目名称:jose,代码行数:18,代码来源:JWS.php

示例10: prepareGrantTypeResponse

 /**
  * {@inheritdoc}
  */
 public function prepareGrantTypeResponse(ServerRequestInterface $request, GrantTypeResponseInterface &$grant_type_response)
 {
     $assertion = RequestBody::getParameter($request, 'assertion');
     try {
         Assertion::notNull($assertion, 'Parameter "assertion" is missing.');
         $jwt = $this->getJWTLoader()->load($assertion, $this->key_encryption_key_set, $this->encryption_required);
         Assertion::isInstanceOf($jwt, JWSInterface::class, 'Assertion does not contain signed claims.');
         Assertion::true($jwt->hasClaim('sub'), 'Assertion does not contain "sub" claims.');
     } catch (\Exception $e) {
         throw $this->getExceptionManager()->getBadRequestException(ExceptionManagerInterface::ERROR_INVALID_REQUEST, $e->getMessage());
     }
     //We modify the response:
     // - We add the subject as the client public id
     // - We transmit the JWT to the response for further needs
     $grant_type_response->setClientPublicId($jwt->getClaim('sub'));
     $grant_type_response->setAdditionalData('jwt', $jwt);
 }
开发者ID:spomky-labs,项目名称:oauth2-server-library,代码行数:20,代码来源:JWTBearerGrantType.php

示例11: processUserAccount

 /**
  * {@inheritdoc}
  */
 public function processUserAccount(ServerRequestInterface $request, ResponseInterface &$response, AuthorizationInterface $authorization, UserAccountInterface &$user_account = null)
 {
     // The query parameter 'id_token_hint' and the Id Token Manager are set
     if ($authorization->hasQueryParam('id_token_hint') && null !== $this->getIdTokenManager()) {
         try {
             $id_token_hint = $this->getIdTokenManager()->loadIdToken($authorization->getQueryParam('id_token_hint'));
             Assertion::true($id_token_hint->hasClaim('sub'), 'Invalid "id_token_hint" parameter.');
             $public_id = $this->getIdTokenManager()->getPublicIdFromSubjectIdentifier($id_token_hint->getClaim('sub'));
             Assertion::notNull($public_id, 'Invalid "id_token_hint" parameter.');
             if (null === $user_account) {
                 $user_account = $this->getUserAccountManager()->getUserAccountByPublicId($public_id);
             } else {
                 if ($user_account->getPublicId() !== $public_id) {
                     throw new RedirectToLoginPageException($authorization);
                 }
             }
         } catch (\InvalidArgumentException $e) {
             throw new CreateRedirectionException($authorization, ExceptionManagerInterface::BAD_REQUEST, $e->getMessage());
         }
     }
 }
开发者ID:spomky-labs,项目名称:oauth2-server-library,代码行数:24,代码来源:IdTokenHintExtension.php

示例12: loadRequest

 /**
  * @param array                               $params
  * @param string                              $request
  * @param \OAuth2\Client\ClientInterface|null $client
  *
  * @throws \OAuth2\Exception\BadRequestExceptionInterface
  *
  * @return \Jose\Object\JWSInterface
  */
 private function loadRequest(array $params, $request, ClientInterface &$client = null)
 {
     $jwt = $this->getJWTLoader()->load($request, $this->key_encryption_key_set, $this->require_encryption);
     try {
         Assertion::true($jwt->hasClaims(), 'The request object does not contain claims.');
         $client = $this->getClient(array_merge($params, $jwt->getClaims()));
         $public_key_set = $client->getPublicKeySet();
         Assertion::notNull($public_key_set, 'The client does not have signature capabilities.');
         $this->getJWTLoader()->verify($jwt, $public_key_set);
         $missing_claims = array_keys(array_diff_key(array_flip($this->mandatory_claims), $jwt->getClaims()));
         Assertion::true(0 === count($missing_claims), 'The following mandatory claims are missing: %s.', json_encode($missing_claims));
     } catch (\Exception $e) {
         throw $this->getExceptionManager()->getBadRequestException(ExceptionManagerInterface::ERROR_INVALID_REQUEST_OBJECT, $e->getMessage());
     }
     return $jwt;
 }
开发者ID:spomky-labs,项目名称:oauth2-server-library,代码行数:25,代码来源:AuthorizationRequestLoader.php

示例13: setAddress

 /**
  * @param string $address
  */
 public function setAddress($address)
 {
     Assertion::notNull($address);
     Assertion::string($address);
     $this->address = $address;
 }
开发者ID:DanielVaquero,项目名称:challenges,代码行数:9,代码来源:Merchant.php

示例14: createIdToken

 /**
  * {@inheritdoc}
  */
 public function createIdToken(ClientInterface $client, UserAccountInterface $user_account, $redirect_uri, $claims_locales, array $request_claims, array $scope, array $id_token_claims = [], AccessTokenInterface $access_token = null, AuthCodeInterface $auth_code = null)
 {
     $id_token = $this->createEmptyIdToken();
     $exp = null !== $access_token ? $access_token->getExpiresAt() : time() + $this->getLifetime($client);
     $claims = array_merge($this->getUserinfo()->getUserinfo($client, $user_account, $redirect_uri, $claims_locales, $request_claims, $scope), ['jti' => Base64Url::encode(random_bytes(25)), 'iss' => $this->getIssuer(), 'aud' => [$client->getPublicId(), $this->getIssuer()], 'iat' => time(), 'nbf' => time(), 'exp' => $exp]);
     foreach (['at_hash' => $access_token, 'c_hash' => $auth_code] as $key => $token) {
         if (null !== $token) {
             $claims[$key] = $this->getHash($token->getToken());
         }
     }
     foreach (['last_login_at' => 'auth_time', 'amr' => 'amr', 'acr' => 'acr'] as $claim => $key) {
         if ($user_account->has($claim)) {
             $claims[$key] = $user_account->get($claim);
         }
     }
     $headers = ['typ' => 'JWT', 'alg' => $this->getSignatureAlgorithm()];
     $signature_key = $this->signature_key_set->selectKey('sig', $this->getSignatureAlgorithm());
     Assertion::notNull($signature_key, 'Unable to find a key to sign the ID Token. Please verify the selected key set contains suitable keys.');
     if ($signature_key->has('kid')) {
         $headers['kid'] = $signature_key->get('kid');
     }
     if (!empty($id_token_claims)) {
         $claims = array_merge($claims, $id_token_claims);
     }
     $jwt = $this->jwt_creator->sign($claims, $headers, $signature_key);
     if ($client->hasPublicKeySet() && $client->has('id_token_encrypted_response_alg') && $client->has('id_token_encrypted_response_enc')) {
         $key_set = $client->getPublicKeySet();
         $key = $key_set->selectKey('enc');
         if (null !== $key) {
             $headers = ['typ' => 'JWT', 'jti' => Base64Url::encode(random_bytes(25)), 'alg' => $client->get('id_token_encrypted_response_alg'), 'enc' => $client->get('id_token_encrypted_response_enc')];
             $jwt = $this->jwt_creator->encrypt($jwt, $headers, $key);
         }
     }
     $id_token->setToken($jwt);
     $id_token->setExpiresAt($exp);
     $id_token->setClientPublicId($client->getPublicId());
     $id_token->setResourceOwnerPublicId($user_account->getUserPublicId());
     return $id_token;
 }
开发者ID:spomky-labs,项目名称:oauth2-server-library,代码行数:42,代码来源:IdTokenManager.php

示例15: checkRequestAndClient

 private function checkRequestAndClient(ServerRequestInterface $request, ClientInterface $client)
 {
     Assertion::true($this->isRequestSecured($request), 'The request must be secured.');
     Assertion::true($client->has('registration_access_token'), 'Invalid client.');
     $values = [];
     $token = $this->bearer_token->findToken($request, $values);
     Assertion::notNull($token, 'Initial Access Token is missing or invalid.');
     Assertion::eq($token, $client->get('registration_access_token'), 'Initial Access Token is missing or invalid.');
 }
开发者ID:spomky-labs,项目名称:oauth2-server-library,代码行数:9,代码来源:ClientConfigurationEndpoint.php


注:本文中的Assert\Assertion::notNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。