| Conditions | 10 | 
| Paths | 65 | 
| Total Lines | 27 | 
| Code Lines | 22 | 
| 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  | 
            ||
| 71 | public function unserialize(string $input): JWE  | 
            ||
| 72 |     { | 
            ||
| 73 | $data = json_decode($input, true);  | 
            ||
| 74 |         if (!is_array($data) || !array_key_exists('ciphertext', $data) || array_key_exists('recipients', $data)) { | 
            ||
| 75 |             throw new \InvalidArgumentException('Unsupported input.'); | 
            ||
| 76 | }  | 
            ||
| 77 | |||
| 78 | $ciphertext = Base64Url::decode($data['ciphertext']);  | 
            ||
| 79 | $iv = Base64Url::decode($data['iv']);  | 
            ||
| 80 | $tag = Base64Url::decode($data['tag']);  | 
            ||
| 81 |         $aad = array_key_exists('aad', $data) ? Base64Url::decode($data['aad']) : null; | 
            ||
| 82 |         $encodedSharedProtectedHeader = array_key_exists('protected', $data) ? $data['protected'] : null; | 
            ||
| 83 | $sharedProtectedHeader = $encodedSharedProtectedHeader ? json_decode(Base64Url::decode($encodedSharedProtectedHeader), true) : [];  | 
            ||
| 84 |         $sharedHeader = array_key_exists('unprotected', $data) ? $data['unprotected'] : []; | 
            ||
| 85 |         $encryptedKey = array_key_exists('encrypted_key', $data) ? Base64Url::decode($data['encrypted_key']) : null; | 
            ||
| 86 |         $header = array_key_exists('header', $data) ? $data['header'] : []; | 
            ||
| 87 | |||
| 88 | return JWE::create(  | 
            ||
| 89 | $ciphertext,  | 
            ||
| 90 | $iv,  | 
            ||
| 91 | $tag,  | 
            ||
| 92 | $aad,  | 
            ||
| 93 | $sharedHeader,  | 
            ||
| 94 | $sharedProtectedHeader,  | 
            ||
| 95 | $encodedSharedProtectedHeader,  | 
            ||
| 96 | [Recipient::create($header, $encryptedKey)]);  | 
            ||
| 97 | }  | 
            ||
| 98 | }  | 
            ||
| 99 |