| Conditions | 2 |
| Paths | 2 |
| Total Lines | 52 |
| Code Lines | 18 |
| 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 |
||
| 40 | public function __construct( |
||
| 41 | protected ?IDValue $id = null, |
||
| 42 | protected ?SAMLDateTimeValue $validUntil = null, |
||
| 43 | protected ?DurationValue $cacheDuration = null, |
||
| 44 | ?Extensions $extensions = null, |
||
| 45 | ) { |
||
| 46 | if ($extensions !== null) { |
||
| 47 | $exts = $extensions->getList(); |
||
| 48 | |||
| 49 | /** |
||
| 50 | * MDUI 2.1: this element MUST NOT appear more than once within a given <md:Extensions> element. |
||
| 51 | */ |
||
| 52 | $uiInfo = array_values(array_filter($exts, function ($ext) { |
||
| 53 | return $ext instanceof UIInfo; |
||
| 54 | })); |
||
| 55 | Assert::maxCount($uiInfo, 1, ProtocolViolationException::class); |
||
| 56 | |||
| 57 | /** |
||
| 58 | * MDUI 2.2: this element MUST NOT appear more than once within a given <md:Extensions> element. |
||
| 59 | */ |
||
| 60 | $discoHints = array_values(array_filter($exts, function ($ext) { |
||
| 61 | return $ext instanceof DiscoHints; |
||
| 62 | })); |
||
| 63 | Assert::maxCount($discoHints, 1, ProtocolViolationException::class); |
||
| 64 | |||
| 65 | /** |
||
| 66 | * MDRPI 2.1: this element MUST NOT appear more than once within a given <md:Extensions> element. |
||
| 67 | */ |
||
| 68 | $regInfo = array_values(array_filter($exts, function ($ext) { |
||
| 69 | return $ext instanceof RegistrationInfo; |
||
| 70 | })); |
||
| 71 | Assert::maxCount($regInfo, 1, ProtocolViolationException::class); |
||
| 72 | |||
| 73 | /** |
||
| 74 | * MDRPI 2.2: this element MUST NOT appear more than once within a given <md:Extensions> element. |
||
| 75 | */ |
||
| 76 | $pubInfo = array_values(array_filter($exts, function ($ext) { |
||
|
|
|||
| 77 | return $ext instanceof PublicationInfo; |
||
| 78 | })); |
||
| 79 | Assert::maxCount($regInfo, 1, ProtocolViolationException::class); |
||
| 80 | |||
| 81 | /** |
||
| 82 | * MDRPI 2.3: The <mdrpi:PublicationPath> element MUST NOT appear more than once within the |
||
| 83 | * <md:Extensions> element of a given <md:EntitiesDescriptor> or <md:EntityDescriptor> element. |
||
| 84 | */ |
||
| 85 | $pubPath = array_values(array_filter($exts, function ($ext) { |
||
| 86 | return $ext instanceof PublicationPath; |
||
| 87 | })); |
||
| 88 | Assert::maxCount($pubPath, 1, ProtocolViolationException::class); |
||
| 89 | } |
||
| 90 | |||
| 91 | $this->setExtensions($extensions); |
||
| 92 | } |
||
| 166 |