Conditions | 13 |
Paths | 1536 |
Total Lines | 40 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
48 | public function parseQueryParameters(?array $sessionTicket, Request $request): array |
||
|
|||
49 | { |
||
50 | $forceAuthn = isset($_GET['renew']) && $_GET['renew']; |
||
51 | $sessionRenewId = $sessionTicket ? $sessionTicket['renewId'] : null; |
||
52 | |||
53 | $query = []; |
||
54 | |||
55 | if ($sessionRenewId && $forceAuthn) { |
||
56 | $query['renewId'] = $sessionRenewId; |
||
57 | } |
||
58 | |||
59 | if (isset($_REQUEST['service'])) { |
||
60 | $query['service'] = $_REQUEST['service']; |
||
61 | } |
||
62 | |||
63 | if (isset($_REQUEST['TARGET'])) { |
||
64 | $query['TARGET'] = $_REQUEST['TARGET']; |
||
65 | } |
||
66 | |||
67 | if (isset($_REQUEST['method'])) { |
||
68 | $query['method'] = $_REQUEST['method']; |
||
69 | } |
||
70 | |||
71 | if (isset($_REQUEST['renew'])) { |
||
72 | $query['renew'] = $_REQUEST['renew']; |
||
73 | } |
||
74 | |||
75 | if (isset($_REQUEST['gateway'])) { |
||
76 | $query['gateway'] = $_REQUEST['gateway']; |
||
77 | } |
||
78 | |||
79 | if (\array_key_exists('language', $_GET)) { |
||
80 | $query['language'] = \is_string($_GET['language']) ? $_GET['language'] : null; |
||
81 | } |
||
82 | |||
83 | if (isset($_REQUEST['debugMode'])) { |
||
84 | $query['debugMode'] = $_REQUEST['debugMode']; |
||
85 | } |
||
86 | |||
87 | return $query; |
||
88 | } |
||
107 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.