Conditions | 11 |
Paths | 15 |
Total Lines | 33 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 9 | ||
Bugs | 4 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
51 | * @throws \InvalidArgumentException |
||
52 | */ |
||
53 | public function verifyWithKey(JWSInterface $jws, JWKInterface $jwk, $detached_payload = null) |
||
54 | { |
||
55 | $jwk_set = new JWKSet(); |
||
56 | $jwk_set = $jwk_set->addKey($jwk); |
||
57 | |||
58 | return $this->verifyWithKeySet($jws, $jwk_set, $detached_payload); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | * |
||
64 | * @throws \InvalidArgumentException |
||
65 | */ |
||
66 | public function verifyWithKeySet(JWSInterface $jws, JWKSetInterface $jwk_set, $detached_payload = null) |
||
67 | { |
||
68 | if (null !== $detached_payload && !empty($jws->getEncodedPayload())) { |
||
69 | throw new \InvalidArgumentException('A detached payload is set, but the JWS already has a payload.'); |
||
70 | } |
||
71 | if (0 === count($jwk_set)) { |
||
72 | throw new \InvalidArgumentException('No key in the key set.'); |
||
73 | } |
||
74 | foreach ($jws->getSignatures() as $signature) { |
||
75 | $input = $signature->getEncodedProtectedHeaders().'.'.(null === $detached_payload ? $jws->getEncodedPayload() : $detached_payload); |
||
76 | |||
77 | foreach ($jwk_set->getKeys() as $jwk) { |
||
78 | $algorithm = $this->getAlgorithm($signature); |
||
79 | if (!$this->checkKeyUsage($jwk, 'verification')) { |
||
80 | continue; |
||
81 | } |
||
82 | if (!$this->checkKeyAlgorithm($jwk, $algorithm->getAlgorithmName())) { |
||
83 | continue; |
||
84 | } |
||
123 |