| Conditions | 2 |
| Paths | 2 |
| Total Lines | 62 |
| 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 |
||
| 40 | public function __construct( |
||
| 41 | protected array $children, |
||
| 42 | ) { |
||
| 43 | Assert::maxCount($children, C::UNBOUNDED_LIMIT); |
||
| 44 | Assert::allIsInstanceOfAny($children, [Assertion::class, Attribute::class]); |
||
| 45 | |||
| 46 | $assertions = array_filter($children, function ($child) { |
||
| 47 | return $child instanceof Assertion; |
||
| 48 | }); |
||
| 49 | |||
| 50 | foreach ($assertions as $assertion) { |
||
| 51 | $statements = array_merge( |
||
| 52 | $assertion->getAttributeStatements(), |
||
| 53 | $assertion->getAuthnStatements(), |
||
| 54 | $assertion->getStatements(), |
||
| 55 | ); |
||
| 56 | |||
| 57 | Assert::allIsInstanceOf( |
||
| 58 | $statements, |
||
| 59 | AttributeStatement::class, |
||
| 60 | '<saml:Asssertion> elements in an <mdattr:EntityAttributes> may only contain AttributeStatements', |
||
| 61 | ProtocolViolationException::class, |
||
| 62 | ); |
||
| 63 | Assert::count( |
||
| 64 | $statements, |
||
| 65 | 1, |
||
| 66 | 'One (and only one) <saml:AttributeStatement> MUST be included ' |
||
| 67 | . 'in a <saml:Assertion> inside a <mdattr:EntityAttribute>', |
||
| 68 | ProtocolViolationException::class, |
||
| 69 | ); |
||
| 70 | Assert::notNull( |
||
| 71 | Assertion::fromXML($assertion->toXML())->getSignature(), |
||
| 72 | 'Every <saml:Assertion> inside a <mdattr:EntityAttributes> must be individually signed', |
||
| 73 | ProtocolViolationException::class, |
||
| 74 | ); |
||
| 75 | |||
| 76 | $subject = $assertion->getSubject(); |
||
| 77 | Assert::notNull( |
||
| 78 | $subject, |
||
| 79 | 'Every <saml:Assertion> inside a <mdattr:EntityAttributes> must contain a Subject', |
||
| 80 | ProtocolViolationException::class, |
||
| 81 | ); |
||
| 82 | |||
| 83 | Assert::isEmpty( |
||
| 84 | $subject->getSubjectConfirmation(), |
||
| 85 | 'Every <saml:Assertion> inside a <mdattr:EntityAttributes> must NOT contain any SubjectConfirmation', |
||
| 86 | ProtocolViolationException::class, |
||
| 87 | ); |
||
| 88 | |||
| 89 | /** @var \SimpleSAML\SAML2\XML\saml\NameID|null $nameId */ |
||
| 90 | $nameId = $subject?->getIdentifier(); |
||
| 91 | Assert::isInstanceOf( |
||
| 92 | $nameId, |
||
| 93 | NameID::class, |
||
| 94 | 'Every <saml:Assertion> inside a <mdattr:EntityAttributes> must contain a NameID', |
||
| 95 | ProtocolViolationException::class, |
||
| 96 | ); |
||
| 97 | Assert::same( |
||
| 98 | $nameId?->getFormat()->getValue(), |
||
| 99 | C::NAMEID_ENTITY, |
||
| 100 | sprintf('The NameID format must be %s', C::NAMEID_ENTITY), |
||
| 101 | ProtocolViolationException::class, |
||
| 102 | ); |
||
| 176 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths