Validator::addConstraintValidator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\Response\Validation;
6
7
use SimpleSAML\SAML2\XML\samlp\Response;
8
9
class Validator
10
{
11
    /** @var \SimpleSAML\SAML2\Response\Validation\ConstraintValidator[] */
12
    protected array $constraints = [];
13
14
15
    /**
16
     * @param \SimpleSAML\SAML2\Response\Validation\ConstraintValidator $constraint
17
     */
18
    public function addConstraintValidator(ConstraintValidator $constraint): void
19
    {
20
        $this->constraints[] = $constraint;
21
    }
22
23
24
    /**
25
     * @param \SimpleSAML\SAML2\XML\samlp\Response $response
26
     * @return \SimpleSAML\SAML2\Response\Validation\Result
27
     */
28
    public function validate(Response $response): Result
29
    {
30
        $result = new Result();
31
        foreach ($this->constraints as $validator) {
32
            $validator->validate($response, $result);
33
        }
34
35
        return $result;
36
    }
37
}
38