Passed
Push — master ( 92085d...93354f )
by Tim
02:29
created

URIElementTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 22
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateContent() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML;
6
7
use SimpleSAML\Assert\Assert;
8
use SimpleSAML\SAML2\Assert\Assert as SAMLAssert;
9
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
10
use SimpleSAML\XML\Exception\SchemaViolationException;
11
use SimpleSAML\XML\URIElementTrait as BaseURIElementTrait;
12
13
/**
14
 * Trait extending the default URIElementTrait to comply with the restrictions added by the SAML 2.0 specifications.
15
 *
16
 * @package simplesamlphp/saml2
17
 */
18
trait URIElementTrait
19
{
20
    use BaseURIElementTrait;
21
22
    /**
23
     * Validate the content of the element.
24
     *
25
     * @param string $content  The value to go in the XML textContent
26
     * @throws \Exception on failure
27
     * @return void
28
     */
29
    protected function validateContent(string $content): void
30
    {
31
        /**
32
         * 1.3.2 URI Values
33
         *
34
         * Unless otherwise indicated in this specification, all URI reference values used within SAML-defined
35
         * elements or attributes MUST consist of at least one non-whitespace character, and are REQUIRED to be
36
         * absolute [RFC 2396].
37
         */
38
        Assert::notWhitespaceOnly($content, ProtocolViolationException::class);
39
        SAMLAssert::validURI($content, SchemaViolationException::class);
40
    }
41
}
42