Passed
Pull Request — master (#6)
by Tim
12:09
created

AnyURITrait::validAnyURI()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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