[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace Lcobucci\JWT\Validation; 4 5 use Lcobucci\JWT\Token; 6 7 final class Validator implements \Lcobucci\JWT\Validator 8 { 9 public function assert(Token $token, Constraint ...$constraints) 10 { 11 if ($constraints === []) { 12 throw new NoConstraintsGiven('No constraint given.'); 13 } 14 15 $violations = []; 16 17 foreach ($constraints as $constraint) { 18 $this->checkConstraint($constraint, $token, $violations); 19 } 20 21 if ($violations) { 22 throw RequiredConstraintsViolated::fromViolations(...$violations); 23 } 24 } 25 26 /** @param ConstraintViolation[] $violations */ 27 private function checkConstraint( 28 Constraint $constraint, 29 Token $token, 30 array &$violations 31 ) { 32 try { 33 $constraint->assert($token); 34 } catch (ConstraintViolation $e) { 35 $violations[] = $e; 36 } 37 } 38 39 public function validate(Token $token, Constraint ...$constraints) 40 { 41 if ($constraints === []) { 42 throw new NoConstraintsGiven('No constraint given.'); 43 } 44 45 try { 46 foreach ($constraints as $constraint) { 47 $constraint->assert($token); 48 } 49 50 return true; 51 } catch (ConstraintViolation $e) { 52 return false; 53 } 54 } 55 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |