PreconditionNotMetException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 4
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFromValidationResult() 0 8 1
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