Conditions | 6 |
Paths | 9 |
Total Lines | 63 |
Code Lines | 39 |
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 |
||
41 | public function invokeTest() |
||
42 | { |
||
43 | // Test LDAP configuration |
||
44 | $confTest = new TestCase\AuthSource\Ldap\Configuration( |
||
45 | $this, |
||
46 | new TestData(['authSourceData' => $this->authSourceData]) |
||
47 | ); |
||
48 | $confTestResult = $confTest->getTestResult(); |
||
49 | $this->addTestResult($confTestResult); |
||
50 | |||
51 | if ($confTestResult->getState() === State::OK) { |
||
52 | $connection = $confTestResult->getOutput('connection'); |
||
53 | |||
54 | // Test connection for each configured LDAP-server |
||
55 | foreach ($this->hosts as $hostname) { |
||
56 | $preparedTestData = $this->prepareConnection($hostname, $this->authSourceData); |
||
57 | $connTest = new TestCase\Network\ConnectUri( |
||
58 | $this, |
||
59 | new TestData($preparedTestData) |
||
60 | ); |
||
61 | $connTestResult = $connTest->getTestResult(); |
||
62 | $this->addTestResult($connTestResult); |
||
63 | |||
64 | if ($connTestResult->getState() === State::OK) { |
||
65 | $certData = $connTestResult->getOutput('certData'); |
||
66 | |||
67 | // Test certificate when available |
||
68 | if ($certData !== null) { |
||
69 | $certTest = new TestCase\Cert( |
||
70 | $this, |
||
71 | new TestData(['certData' => $certData, 'category' => 'LDAP Server Certificate']) |
||
72 | ); |
||
73 | $certTestResult = $certTest->getTestResult(); |
||
74 | $this->addTestResult($certTestResult); |
||
75 | } |
||
76 | } |
||
77 | } |
||
78 | |||
79 | // Test bind |
||
80 | $testData = new TestData([ |
||
81 | 'authSourceData' => $this->authSourceData, |
||
82 | 'connection' => $connection |
||
83 | ]); |
||
84 | $bindTest = new TestCase\AuthSource\Ldap\Bind( |
||
85 | $this, |
||
86 | $testData |
||
87 | ); |
||
88 | $bindTestResult = $bindTest->getTestResult(); |
||
89 | $this->addTestResult($bindTestResult); |
||
90 | |||
91 | if ($bindTestResult->getState() === State::OK) { |
||
92 | // Test search |
||
93 | $testData = new TestData([ |
||
94 | 'authSourceData' => $this->authSourceData, |
||
95 | 'connection' => $connection |
||
96 | ]); |
||
97 | |||
98 | $searchTest = new TestCase\AuthSource\Ldap\Search( |
||
99 | $this, |
||
100 | $testData |
||
101 | ); |
||
102 | $searchTestResult = $searchTest->getTestResult(); |
||
103 | $this->addTestResult($searchTestResult); |
||
104 | } |
||
132 |