| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 63 | 
| 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  | 
            ||
| 71 | |||
| 72 | $subject = $assertion->getSubject();  | 
            ||
| 73 | Assert::notNull(  | 
            ||
| 74 | $subject,  | 
            ||
| 75 | 'Every <saml:Assertion> inside a <mdattr:EntityAttributes> must contain a Subject',  | 
            ||
| 76 | ProtocolViolationException::class,  | 
            ||
| 77 | );  | 
            ||
| 78 | |||
| 79 | Assert::isEmpty(  | 
            ||
| 80 | $subject?->getSubjectConfirmation(),  | 
            ||
| 81 | 'Every <saml:Assertion> inside a <mdattr:EntityAttributes> must NOT contain any SubjectConfirmation',  | 
            ||
| 82 | ProtocolViolationException::class,  | 
            ||
| 83 | );  | 
            ||
| 84 | |||
| 85 | $nameId = $subject?->getIdentifier();  | 
            ||
| 86 | Assert::isInstanceOf(  | 
            ||
| 87 | $nameId,  | 
            ||
| 88 | NameID::class,  | 
            ||
| 89 | 'Every <saml:Assertion> inside a <mdattr:EntityAttributes> must contain a NameID',  | 
            ||
| 90 | ProtocolViolationException::class,  | 
            ||
| 91 | );  | 
            ||
| 92 | Assert::same(  | 
            ||
| 93 | $nameId?->getFormat(),  | 
            ||
| 94 | C::NAMEID_ENTITY,  | 
            ||
| 95 |                 sprintf('The NameID format must be %s', C::NAMEID_ENTITY), | 
            ||
| 96 | ProtocolViolationException::class,  | 
            ||
| 97 | );  | 
            ||
| 98 | }  | 
            ||
| 99 | }  | 
            ||
| 100 | |||
| 101 | |||
| 102 | /**  | 
            ||
| 103 | * Collect the value of the children-property  | 
            ||
| 104 | *  | 
            ||
| 105 | * @return (\SimpleSAML\SAML2\XML\saml\Assertion|\SimpleSAML\SAML2\XML\saml\Attribute)[]  | 
            ||
| 106 | */  | 
            ||
| 107 | public function getChildren(): array  | 
            ||
| 108 |     { | 
            ||
| 109 | return $this->children;  | 
            ||
| 110 | }  | 
            ||
| 111 | |||
| 112 | |||
| 113 | /**  | 
            ||
| 114 | * Add the value to the children-property  | 
            ||
| 115 | *  | 
            ||
| 116 | * @param \SimpleSAML\SAML2\XML\saml\Assertion|\SimpleSAML\SAML2\XML\saml\Attribute $child  | 
            ||
| 117 | * @return void  | 
            ||
| 118 | * @throws \SimpleSAML\Assert\AssertionFailedException  | 
            ||
| 119 | */  | 
            ||
| 120 | public function addChild($child): void  | 
            ||
| 121 |     { | 
            ||
| 122 | $this->children = array_merge($this->children, [$child]);  | 
            ||
| 123 | }  | 
            ||
| 124 | |||
| 125 | |||
| 126 | /**  | 
            ||
| 127 | * Convert XML into a EntityAttributes  | 
            ||
| 128 | *  | 
            ||
| 129 | * @param \DOMElement $xml The XML element we should load  | 
            ||
| 130 | * @return self  | 
            ||
| 131 | *  | 
            ||
| 132 | * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException  | 
            ||
| 133 | * if the qualified name of the supplied element is wrong  | 
            ||
| 134 | */  | 
            ||
| 177 |