Conditions | 7 |
Paths | 11 |
Total Lines | 54 |
Code Lines | 38 |
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 |
||
38 | public function invokeTest() |
||
39 | { |
||
40 | if ($this->checkAuthSources === true) { |
||
41 | $authSources = $this->authSourceConfig->getOptions(); |
||
42 | } else if (is_array($this->checkAuthSources)) { |
||
43 | $authSources = array_intersect($this->authSourceConfig->getOptions(), $this->checkAuthSources); |
||
44 | } else { // false or invalid value |
||
45 | return; |
||
46 | } |
||
47 | |||
48 | $configuration = $this->getConfiguration(); |
||
49 | $output = []; |
||
50 | |||
51 | foreach ($authSources as $authSourceId) { |
||
52 | $authSourceData = $this->authSourceConfig->getValue($authSourceId); |
||
53 | $input = array( |
||
54 | 'authSourceId' => $authSourceId, |
||
55 | 'authSourceData' => $authSourceData |
||
56 | ); |
||
57 | $testData = new TestData($input); |
||
58 | |||
59 | switch ($authSourceData[0]) { |
||
60 | case 'ldap:LDAP': |
||
61 | $ldapTest = new AuthSource\Ldap($configuration, $testData); |
||
62 | $this->addTestResults($ldapTest->getTestResults()); |
||
63 | $output[$authSourceId] = $ldapTest->getArrayizeTestResults(); |
||
64 | break; |
||
65 | case 'negotiate:Negotiate': |
||
66 | $negoTest = new AuthSource\Negotiate($configuration, $testData); |
||
67 | $this->addTestResults($negoTest->getTestResults()); |
||
68 | |||
69 | // We need to do some convertions from Negotiate > LDAP |
||
70 | $this->convertAuthSourceData($authSourceData); |
||
71 | $testData->setInput($authSourceData, 'authSourceData'); |
||
72 | |||
73 | $ldapTest = new AuthSource\Ldap($configuration, $testData); |
||
74 | $this->addTestResults($ldapTest->getTestResults()); |
||
75 | |||
76 | $output[$authSourceId] = array_merge($negoTest->getArrayizeTestResults() ,$ldapTest->getArrayizeTestResults()); |
||
77 | break; |
||
78 | case 'multiauth:MultiAuth': |
||
79 | // Relies on other authSources |
||
80 | continue 2; |
||
81 | default: |
||
82 | // Not implemented |
||
83 | continue 2; |
||
84 | } |
||
85 | } |
||
86 | |||
87 | $state = $this->calculateState(); |
||
88 | $testResult = new TestResult('Authentication sources'); |
||
89 | $testResult->setState($state); |
||
90 | $testResult->setOutput($output); |
||
91 | $this->setTestResult($testResult); |
||
92 | } |
||
121 |