Passed
Push — master ( 765b41...e6bf79 )
by Tim
03:49 queued 01:38
created

SAMLAnyURITrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 9
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validSAMLAnyURI() 0 18 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML11\Assert;
6
7
use SimpleSAML\Assert\AssertionFailedException;
8
use SimpleSAML\SAML11\Exception\ProtocolViolationException;
9
10
/**
11
 * @package simplesamlphp/saml11
12
 */
13
trait SAMLAnyURITrait
14
{
15
    /**
16
     * @param string $value
17
     * @param string $message
18
     */
19
    protected static function validSAMLAnyURI(string $value, string $message = ''): void
20
    {
21
        parent::validAnyURI($value, $message);
22
23
        try {
24
            /**
25
             * 1.2.1 String and URI Values
26
             *
27
             * Unless otherwise indicated in this specification, all URI reference values MUST consist
28
             * of at least one non-whitespace character
29
             */
30
            static::notWhitespaceOnly(
31
                $value,
32
                $message ?: '%s is not a SAML1.1-compliant URI',
33
                ProtocolViolationException::class,
34
            );
35
        } catch (AssertionFailedException $e) {
36
            throw new ProtocolViolationException($e->getMessage());
37
        }
38
    }
39
}
40