| Conditions | 7 |
| Paths | 11 |
| Total Lines | 54 |
| Code Lines | 38 |
| 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 |
||
| 17 | protected function invokeTestSuite() |
||
| 18 | { |
||
| 19 | $configuration = $this->getConfiguration(); |
||
| 20 | $moduleConfig = $configuration->getModuleConfig(); |
||
| 21 | $authsourceConfig = $configuration->getAuthsourceConfig(); |
||
| 22 | $checkAuthsources = $moduleConfig->getValue('check_authsources', true); |
||
| 23 | |||
| 24 | if ($checkAuthsources === true) { |
||
| 25 | $authsources = $authsourceConfig->getOptions(); |
||
| 26 | } else if (is_array($checkAuthsources)) { |
||
| 27 | $authsources = array_intersect($authsourceConfig->getOptions(), $checkAuthsources); |
||
| 28 | } else { // false or invalid value |
||
| 29 | return; |
||
| 30 | } |
||
| 31 | |||
| 32 | foreach ($authsources as $authsourceId) { |
||
| 33 | $authsourceData = $authsourceConfig->getValue($authsourceId); |
||
| 34 | $testData = new TestData( |
||
| 35 | array( |
||
| 36 | 'authsourceId' => $authsourceId, |
||
| 37 | 'authsourceData' => $authsourceData |
||
| 38 | ) |
||
| 39 | ); |
||
| 40 | |||
| 41 | switch ($authsourceData[0]) { |
||
| 42 | case 'ldap:LDAP': |
||
| 43 | $test = new AuthSource\Ldap($configuration, $testData); |
||
| 44 | $this->addTest($test); |
||
| 45 | $this->addMessages($test->getMessages(), $authsourceId); |
||
| 46 | break; |
||
| 47 | case 'negotiate:Negotiate': |
||
| 48 | $test = new AuthSource\Negotiate($configuration, $testData); |
||
| 49 | $this->addTest($test); |
||
| 50 | $this->addMessages($test->getMessages(), $authsourceId); |
||
| 51 | |||
| 52 | $this->convertAuthsourceData(); |
||
|
|
|||
| 53 | $testData->setInput($authsourceData, 'authsourceData'); |
||
| 54 | |||
| 55 | $ldapTest = new AuthSource\Ldap($configuration, $testData); |
||
| 56 | $this->addTest($ldapTest); |
||
| 57 | $this->addMessages($ldapTest->getMessages(), $authsourceId); |
||
| 58 | |||
| 59 | break; |
||
| 60 | case 'multiauth:MultiAuth': |
||
| 61 | // Relies on other authsources |
||
| 62 | continue 2; |
||
| 63 | default: |
||
| 64 | // Not implemented |
||
| 65 | continue 2; |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | $this->calculateState(); |
||
| 70 | } |
||
| 71 | |||
| 98 |
This check looks for function calls that miss required arguments.