| Conditions | 7 | 
| Paths | 4 | 
| Total Lines | 75 | 
| Code Lines | 45 | 
| 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  | 
            ||
| 60 | public function invokeTest()  | 
            ||
| 61 |     { | 
            ||
| 62 | // Test LDAP configuration  | 
            ||
| 63 | $confTest = new TestCase\AuthSource\Ldap\Configuration(  | 
            ||
| 64 | new TestData(['authSourceData' => $this->authSourceData])  | 
            ||
| 65 | );  | 
            ||
| 66 | $confTestResult = $confTest->getTestResult();  | 
            ||
| 67 | $this->addTestResult($confTestResult);  | 
            ||
| 68 | |||
| 69 |         if ($confTestResult->getState() === State::OK) { | 
            ||
| 70 |             $connection = $confTestResult->getOutput('connection'); | 
            ||
| 71 | |||
| 72 | // Test connection for each configured LDAP-server  | 
            ||
| 73 | $failure = count($this->hosts);  | 
            ||
| 74 |             foreach ($this->hosts as $hostname) { | 
            ||
| 75 | $preparedTestData = $this->prepareConnection($hostname);  | 
            ||
| 76 | $connTest = new TestCase\Network\ConnectUri(  | 
            ||
| 77 | new TestData($preparedTestData)  | 
            ||
| 78 | );  | 
            ||
| 79 | $connTestResult = $connTest->getTestResult();  | 
            ||
| 80 | $this->addTestResult($connTestResult);  | 
            ||
| 81 | |||
| 82 |                 if ($connTestResult->getState() === State::OK) { | 
            ||
| 83 |                     $certData = $connTestResult->getOutput('certData'); | 
            ||
| 84 | |||
| 85 | // Test certificate when available  | 
            ||
| 86 |                     if ($certData !== null) { | 
            ||
| 87 | $certTest = new TestCase\Cert(  | 
            ||
| 88 | new TestData([  | 
            ||
| 89 | 'certData' => $certData,  | 
            ||
| 90 | 'category' => 'LDAP Server Certificate',  | 
            ||
| 91 | 'certExpirationWarning' => $this->certExpirationWarning,  | 
            ||
| 92 | ])  | 
            ||
| 93 | );  | 
            ||
| 94 | $certTestResult = $certTest->getTestResult();  | 
            ||
| 95 | $this->addTestResult($certTestResult);  | 
            ||
| 96 | }  | 
            ||
| 97 | $failure--;  | 
            ||
| 98 | }  | 
            ||
| 99 | }  | 
            ||
| 100 | |||
| 101 |             if ($failure === 0) { | 
            ||
| 102 | // Test bind  | 
            ||
| 103 | $testData = new TestData([  | 
            ||
| 104 | 'authSourceData' => $this->authSourceData,  | 
            ||
| 105 | 'connection' => $connection  | 
            ||
| 106 | ]);  | 
            ||
| 107 | $bindTest = new TestCase\AuthSource\Ldap\Bind(  | 
            ||
| 108 | $testData  | 
            ||
| 109 | );  | 
            ||
| 110 | $bindTestResult = $bindTest->getTestResult();  | 
            ||
| 111 | $this->addTestResult($bindTestResult);  | 
            ||
| 112 | |||
| 113 |                 if ($bindTestResult->getState() === State::OK) { | 
            ||
| 114 | // Test search  | 
            ||
| 115 | $testData = new TestData([  | 
            ||
| 116 | 'authSourceData' => $this->authSourceData,  | 
            ||
| 117 | 'connection' => $connection  | 
            ||
| 118 | ]);  | 
            ||
| 119 | |||
| 120 | $searchTest = new TestCase\AuthSource\Ldap\Search(  | 
            ||
| 121 | $testData  | 
            ||
| 122 | );  | 
            ||
| 123 | $searchTestResult = $searchTest->getTestResult();  | 
            ||
| 124 | $this->addTestResult($searchTestResult);  | 
            ||
| 125 | }  | 
            ||
| 126 | }  | 
            ||
| 127 | unset($connection);  | 
            ||
| 128 | }  | 
            ||
| 129 | |||
| 130 | $state = $this->calculateState();  | 
            ||
| 131 | |||
| 132 |         $testResult = new TestResult('LDAP Authentication'); | 
            ||
| 133 | $testResult->setState($state);  | 
            ||
| 134 | $this->setTestResult($testResult);  | 
            ||
| 135 | }  | 
            ||
| 172 |