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