Conditions | 4 |
Paths | 6 |
Total Lines | 52 |
Code Lines | 30 |
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 |
||
55 | public function invokeTest() |
||
56 | { |
||
57 | // Check network connection to full public URL |
||
58 | $input = [ |
||
59 | 'uri' => 'ssl://'.$this->serverName.':'.$this->serverPort, |
||
60 | 'context' => stream_context_create([ |
||
61 | "ssl" => [ |
||
62 | "capture_peer_cert" => true, |
||
63 | "verify_peer" => false, |
||
64 | "verify_peer_name" => false |
||
65 | ] |
||
66 | ]), |
||
67 | ]; |
||
68 | |||
69 | $connTest = new TestCase\Network\ConnectUri(new TestData($input)); |
||
70 | $connTestResult = $connTest->getTestResult(); |
||
71 | |||
72 | $this->addTestResult($connTest->getTestResult()); |
||
73 | |||
74 | if ($connTestResult->getState() === State::OK) { |
||
75 | // We were able to connect |
||
76 | if (Utils\HTTP::isHTTPS()) { |
||
77 | // Check Service Communications Certificate |
||
78 | $certData = $connTestResult->getOutput('certData'); |
||
79 | |||
80 | $input = [ |
||
81 | 'category' => 'Service Communications Certificate', |
||
82 | 'certData' => $certData, |
||
83 | 'certExpirationWarning' => $this->certExpirationWarning, |
||
84 | ]; |
||
85 | |||
86 | $certTest = new TestCase\Cert(new TestData($input)); |
||
87 | $this->addTestResult($certTest->getTestResult()); |
||
88 | } |
||
89 | } |
||
90 | |||
91 | // Check metadata signing certificate when available |
||
92 | if (is_string($this->metadataCert)) { |
||
93 | $input = array( |
||
94 | 'certFile' => Utils\Config::getCertPath($this->metadataCert), |
||
95 | 'category' => 'Metadata Signing Certificate', |
||
96 | 'certExpirationWarning' => $this->certExpirationWarning, |
||
97 | ); |
||
98 | $testData = new TestData($input); |
||
99 | |||
100 | $test = new TestCase\Cert\File($testData); |
||
101 | $this->addTestResult($test->getTestResult()); |
||
102 | } |
||
103 | |||
104 | $testResult = new TestResult('Configuration', ''); |
||
105 | $testResult->setState($this->calculateState()); |
||
106 | $this->setTestResult($testResult); |
||
107 | } |
||
109 |