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