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