| Conditions | 13 |
| Paths | 1536 |
| Total Lines | 40 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 63 | function parseQueryParameters(?array $sessionTicket): array |
||
| 64 | { |
||
| 65 | $forceAuthn = isset($_GET['renew']) && $_GET['renew']; |
||
| 66 | $sessionRenewId = $sessionTicket ? $sessionTicket['renewId'] : null; |
||
| 67 | |||
| 68 | $query = []; |
||
| 69 | |||
| 70 | if ($sessionRenewId && $forceAuthn) { |
||
| 71 | $query['renewId'] = $sessionRenewId; |
||
| 72 | } |
||
| 73 | |||
| 74 | if (isset($_REQUEST['service'])) { |
||
| 75 | $query['service'] = $_REQUEST['service']; |
||
| 76 | } |
||
| 77 | |||
| 78 | if (isset($_REQUEST['TARGET'])) { |
||
| 79 | $query['TARGET'] = $_REQUEST['TARGET']; |
||
| 80 | } |
||
| 81 | |||
| 82 | if (isset($_REQUEST['method'])) { |
||
| 83 | $query['method'] = $_REQUEST['method']; |
||
| 84 | } |
||
| 85 | |||
| 86 | if (isset($_REQUEST['renew'])) { |
||
| 87 | $query['renew'] = $_REQUEST['renew']; |
||
| 88 | } |
||
| 89 | |||
| 90 | if (isset($_REQUEST['gateway'])) { |
||
| 91 | $query['gateway'] = $_REQUEST['gateway']; |
||
| 92 | } |
||
| 93 | |||
| 94 | if (array_key_exists('language', $_GET)) { |
||
| 95 | $query['language'] = is_string($_GET['language']) ? $_GET['language'] : null; |
||
| 96 | } |
||
| 97 | |||
| 98 | if (isset($_REQUEST['debugMode'])) { |
||
| 99 | $query['debugMode'] = $_REQUEST['debugMode']; |
||
| 100 | } |
||
| 101 | |||
| 102 | return $query; |
||
| 103 | } |
||
| 104 |