Conditions | 7 |
Paths | 11 |
Total Lines | 52 |
Code Lines | 35 |
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 |
||
39 | protected function invokeTestSuite() |
||
40 | { |
||
41 | if ($this->checkAuthSources === true) { |
||
42 | $authSources = $this->authSourceConfig->getOptions(); |
||
43 | } else if (is_array($this->checkAuthSources)) { |
||
44 | $authSources = array_intersect($this->authSourceConfig->getOptions(), $this->checkAuthSources); |
||
45 | } else { // false or invalid value |
||
46 | return; |
||
47 | } |
||
48 | |||
49 | $configuration = $this->getConfiguration(); |
||
50 | foreach ($authSources as $authSourceId) { |
||
51 | $authSourceData = $this->authSourceConfig->getValue($authSourceId); |
||
52 | $input = array( |
||
53 | 'authSourceId' => $authSourceId, |
||
54 | 'authSourceData' => $authSourceData |
||
55 | ); |
||
56 | $testData = new TestData($input); |
||
57 | |||
58 | switch ($authSourceData[0]) { |
||
59 | case 'ldap:LDAP': |
||
60 | $test = new AuthSource\Ldap($configuration, $testData); |
||
61 | $testResult = $test->getTestResult(); |
||
|
|||
62 | $this->addTestResult($test->getTestResult()); |
||
63 | //$this->addMessages($test->getMessages(), $authSourceId); |
||
64 | break; |
||
65 | case 'negotiate:Negotiate': |
||
66 | $test = new AuthSource\Negotiate($configuration, $testData); |
||
67 | $testResult = $test->getTestResult(); |
||
68 | $this->addTestResult($test->getTestResult()); |
||
69 | //$this->addMessages($test->getMessages(), $authSourceId); |
||
70 | |||
71 | // We need to do some convertions from Negotiate > LDAP |
||
72 | $this->convertAuthSourceData($authSourceData); |
||
73 | $testData->setInput($authSourceData, 'authSourceData'); |
||
74 | |||
75 | $ldapTest = new AuthSource\Ldap($configuration, $testData); |
||
76 | $testResult = $test->getTestResult(); |
||
77 | $this->addTestResult($test->getTestResult()); |
||
78 | //$this->addMessages($ldapTest->getMessages(), $authSourceId); |
||
79 | break; |
||
80 | case 'multiauth:MultiAuth': |
||
81 | // Relies on other authSources |
||
82 | continue 2; |
||
83 | default: |
||
84 | // Not implemented |
||
85 | continue 2; |
||
86 | } |
||
87 | } |
||
88 | |||
89 | $this->calculateState(); |
||
90 | } |
||
91 | |||
120 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.