1 | <?php |
||
19 | class ClaimCheckerManager |
||
20 | { |
||
21 | /** |
||
22 | * @var ClaimChecker[] |
||
23 | */ |
||
24 | private $checkers = []; |
||
25 | |||
26 | /** |
||
27 | * ClaimCheckerManager constructor. |
||
28 | * |
||
29 | * @param ClaimChecker[] $checkers |
||
30 | */ |
||
31 | private function __construct(array $checkers) |
||
37 | |||
38 | /** |
||
39 | * This method creates the ClaimCheckerManager. |
||
40 | * The argument is a list of claim checkers objects. |
||
41 | * |
||
42 | * @param ClaimChecker[] $checkers |
||
43 | * |
||
44 | * @return ClaimCheckerManager |
||
45 | */ |
||
46 | public static function create(array $checkers): self |
||
50 | |||
51 | /** |
||
52 | * @param ClaimChecker $checker |
||
53 | * |
||
54 | * @return ClaimCheckerManager |
||
55 | */ |
||
56 | private function add(ClaimChecker $checker): self |
||
63 | |||
64 | /** |
||
65 | * This method returns all checkers handled by this manager. |
||
66 | * |
||
67 | * @return ClaimChecker[] |
||
68 | */ |
||
69 | public function getCheckers(): array |
||
73 | |||
74 | /** |
||
75 | * This method checks all the claims passed as argument. |
||
76 | * All claims are checked against the claim checkers. |
||
77 | * If one fails, the InvalidClaimException is thrown. |
||
78 | * |
||
79 | * This method returns an array with all checked claims. |
||
80 | * It is up to the implementor to decide use the claims that have not been checked. |
||
81 | * |
||
82 | * @param array $claims |
||
83 | * @param string[] $mandatoryClaims |
||
84 | * |
||
85 | * @throws InvalidClaimException |
||
86 | * @throws MissingMandatoryClaimException |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | public function check(array $claims, array $mandatoryClaims = []): array |
||
103 | |||
104 | /** |
||
105 | * @param string[] $mandatoryClaims |
||
106 | * @param array $claims |
||
107 | * |
||
108 | * @throws MissingMandatoryClaimException |
||
109 | */ |
||
110 | private function checkMandatoryClaims(array $mandatoryClaims, array $claims) |
||
121 | } |
||
122 |