createFromValidationResult()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\Response\Exception;
6
7
use SimpleSAML\SAML2\Response\Validation\Result;
8
9
use function implode;
10
use function sprintf;
11
12
/**
13
 * Named exception to indicate that the preconditions for processing the SAML response have not been met.
14
 */
15
class PreconditionNotMetException extends InvalidResponseException
16
{
17
    /**
18
     * @param \SimpleSAML\SAML2\Response\Validation\Result $result
19
     * @return \SimpleSAML\SAML2\Response\Exception\PreconditionNotMetException
20
     */
21
    public static function createFromValidationResult(Result $result): PreconditionNotMetException
22
    {
23
        $message = sprintf(
24
            'Cannot process response, preconditions not met: "%s"',
25
            implode('", "', $result->getErrors()),
26
        );
27
28
        return new self($message);
29
    }
30
}
31