| Conditions | 6 |
| Paths | 12 |
| Total Lines | 54 |
| Code Lines | 30 |
| Lines | 14 |
| Ratio | 25.93 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 45 | protected function invokeTestSuite() |
||
| 46 | { |
||
| 47 | // Check network connection to full public URL |
||
| 48 | $input = [ |
||
| 49 | 'connectString' => 'ssl://'.$hostname.':'.$port, |
||
| 50 | 'context' => stream_context_create([ |
||
| 51 | "ssl" => [ |
||
| 52 | "capture_peer_cert" => true, |
||
| 53 | "verify_peer" => false, |
||
| 54 | "verify_peer_name" => false |
||
| 55 | ] |
||
| 56 | ]), |
||
| 57 | ]; |
||
| 58 | |||
| 59 | $connTest = new TestCase\Network\ConnectUri($this, new TestData($input)); |
||
| 60 | $connTestResult = $connTest->getTestResult(); |
||
| 61 | |||
| 62 | $this->addTest($connTest); |
||
| 63 | |||
| 64 | View Code Duplication | if ($connTestResult->getState() === State::OK) { |
|
| 65 | // Check Service Communications Certificate |
||
| 66 | $certData = $connTestResult->getOutput('certData'); |
||
| 67 | |||
| 68 | if (Utils\HTTP::isHTTPS() && $certData !== null) { |
||
| 69 | $input = [ |
||
| 70 | 'category' => 'Service Communications Certificate', |
||
| 71 | 'certData' => $certData, |
||
| 72 | ]; |
||
| 73 | |||
| 74 | $certTest = new TestCase\Cert\Data($this, new TestData($input)); |
||
| 75 | $this->addTest($certTest); |
||
| 76 | } // else {'Unable to capture peer certificate'} |
||
| 77 | } |
||
| 78 | |||
| 79 | // Check metadata signing certificate when available |
||
| 80 | if (is_string($this->metadataCert)) { |
||
| 81 | $input = array( |
||
| 82 | 'certFile' => Utils\Config::getCertPath($this->metadataCert), |
||
| 83 | 'category' => 'Metadata Signing Certificate' |
||
| 84 | ); |
||
| 85 | $testData = new TestData($input); |
||
| 86 | |||
| 87 | $test = new TestCase\Cert\File($this, $testData); |
||
| 88 | $this->addTest($test); |
||
| 89 | } |
||
| 90 | |||
| 91 | $tests = $this->getTests(); |
||
| 92 | foreach ($tests as $test) |
||
| 93 | { |
||
| 94 | $this->addMessages($test->getMessages()); |
||
| 95 | } |
||
| 96 | |||
| 97 | $this->calculateState(); |
||
| 98 | } |
||
| 99 | } |
||
| 100 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.