| Conditions | 10 |
| Paths | 5 |
| Total Lines | 13 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
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 |
||
| 24 | public function analyze(JWK $jwk, array &$messages) |
||
| 25 | { |
||
| 26 | if ('RSA' !== $jwk->get('kty')) { |
||
| 27 | return; |
||
| 28 | } |
||
| 29 | $n = 8 * mb_strlen(Base64Url::decode($jwk->get('n')), '8bit'); |
||
| 30 | if ($n < 2048) { |
||
| 31 | $messages[] = 'The key length is less than 2048 bits.'; |
||
| 32 | } |
||
| 33 | if ($jwk->has('d') && (!$jwk->has('p') || !$jwk->has('q') || !$jwk->has('dp') || !$jwk->has('dq') || !$jwk->has('p') || !$jwk->has('qi'))) { |
||
| 34 | $messages[] = 'The key is a private RSA key, but Chinese Remainder Theorem primes are missing. These primes are not mandatory, but signatures and decryption processes are faster when available.'; |
||
| 35 | } |
||
| 36 | } |
||
| 37 | } |
||
| 38 |