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