| Conditions | 6 | 
| Paths | 6 | 
| Total Lines | 59 | 
| Code Lines | 38 | 
| 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  | 
            ||
| 52 | public function invokeTest()  | 
            ||
| 53 |     { | 
            ||
| 54 | $input = [  | 
            ||
| 55 | 'entityId' => $this->entityId,  | 
            ||
| 56 | 'entityMetadata' => $this->entityMetadata,  | 
            ||
| 57 | ];  | 
            ||
| 58 | $testData = new TestData($input);  | 
            ||
| 59 | |||
| 60 | $expTest = new TestCase\Metadata\Expiration($testData);  | 
            ||
| 61 | $expTestResult = $expTest->getTestResult();  | 
            ||
| 62 | $expTestResult->setSubject($this->entityId);  | 
            ||
| 63 | $this->addTestResult($expTestResult);  | 
            ||
| 64 | |||
| 65 |         if (array_key_exists('keys', $this->entityMetadata)) { | 
            ||
| 66 | $keys = $this->entityMetadata['keys'];  | 
            ||
| 67 |             foreach ($keys as $key) { | 
            ||
| 68 | $input = array(  | 
            ||
| 69 | 'category' => $this->getType($key),  | 
            ||
| 70 | 'certData' => "-----BEGIN CERTIFICATE-----\n" .chunk_split($key['X509Certificate'], 64)."-----END CERTIFICATE-----\n",  | 
            ||
| 71 | 'certExpirationWarning' => $this->certExpirationWarning,  | 
            ||
| 72 | );  | 
            ||
| 73 | $testData = new TestData($input);  | 
            ||
| 74 | |||
| 75 | $certTest = new TestCase\Cert\Data($testData);  | 
            ||
| 76 | $certTestResult = $certTest->getTestResult();  | 
            ||
| 77 | |||
| 78 | $this->addTestResult($certTestResult);  | 
            ||
| 79 | }  | 
            ||
| 80 |         } else { | 
            ||
| 81 | // saml20-idp-hosted  | 
            ||
| 82 | $files = [];  | 
            ||
| 83 |             if (array_key_exists('certificate', $this->entityMetadata)) { | 
            ||
| 84 | $files[] = $this->entityMetadata['certificate'];  | 
            ||
| 85 | }  | 
            ||
| 86 |             if (array_key_exists('new_certificate', $this->entityMetadata)) { | 
            ||
| 87 | $files[] = $this->entityMetadata['new_certificate'];  | 
            ||
| 88 | }  | 
            ||
| 89 | |||
| 90 |             foreach ($files as $file) { | 
            ||
| 91 | $input = [  | 
            ||
| 92 | 'category' => $this->getType(['signing' => true]),  | 
            ||
| 93 | 'certFile' => \SimpleSAML\Utils\Config::getCertPath($file),  | 
            ||
| 94 | 'certExpirationWarning' => $this->certExpirationWarning,  | 
            ||
| 95 | ];  | 
            ||
| 96 | |||
| 97 | $testData = new TestData($input);  | 
            ||
| 98 | |||
| 99 | $certTest = new TestCase\Cert\File($testData);  | 
            ||
| 100 | $certTestResult = $certTest->getTestResult();  | 
            ||
| 101 | |||
| 102 | $this->addTestResult($certTestResult);  | 
            ||
| 103 | }  | 
            ||
| 104 | }  | 
            ||
| 105 | |||
| 106 | $state = $this->calculateState();  | 
            ||
| 107 | |||
| 108 |         $testResult = new TestResult('Metadata endpoint'); | 
            ||
| 109 | $testResult->setState($state);  | 
            ||
| 110 | $this->setTestResult($testResult);  | 
            ||
| 111 | }  | 
            ||
| 130 |