URIElementTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

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
    /**
24
     * Validate the content of the element.
25
     *
26
     * @param string $content  The value to go in the XML textContent
27
     * @throws \Exception on failure
28
     * @return void
29
     */
30
    protected function validateContent(string $content): void
31
    {
32
        /**
33
         * 1.3.2 URI Values
34
         *
35
         * Unless otherwise indicated in this specification, all URI reference values used within SAML-defined
36
         * elements or attributes MUST consist of at least one non-whitespace character, and are REQUIRED to be
37
         * absolute [RFC 2396].
38
         */
39
        Assert::notWhitespaceOnly($content, ProtocolViolationException::class);
40
        SAMLAssert::validURI($content, SchemaViolationException::class);
41
    }
42
}
43