Passed
Push — master ( b5347c...19d990 )
by Tim
02:04
created

URIElementTrait::validateContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 14
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML11\XML;
6
7
use SimpleSAML\Assert\Assert;
8
use SimpleSAML\SAML11\Exception\ProtocolViolationException;
9
use SimpleSAML\XML\Exception\SchemaViolationException;
10
use SimpleSAML\XML\URIElementTrait as BaseURIElementTrait;
11
12
/**
13
 * Trait extending the default URIElementTrait to comply with the restrictions added by the SAML 1.1 specifications.
14
 *
15
 * @package simplesamlphp/saml11
16
 */
17
trait URIElementTrait
18
{
19
    use BaseURIElementTrait;
20
21
    /**
22
     * Validate the content of the element.
23
     *
24
     * @param string $content  The value to go in the XML textContent
25
     * @throws \Exception on failure
26
     * @return void
27
     */
28
    protected function validateContent(string $content): void
29
    {
30
        /**
31
         * 1.2.1 String and URI Values
32
         *
33
         * All SAML string and URI reference values have the types xsd:string and xsd:anyURI respectively, which
34
         * are built in to the W3C XML Schema Datatypes specification [Schema2]. All strings in SAML messages
35
         * MUST consist of at least one non-whitespace character (whitespace is defined in the XML
36
         * Recommendation [XML] §2.3). Empty and whitespace-only values are disallowed. Also, unless otherwise
37
         * indicated in this specification, all URI reference values MUST consist of at least one non-whitespace
38
         * character, and are strongly RECOMMENDED to be absolute [RFC 2396].
39
         */
40
        Assert::notWhitespaceOnly($content, ProtocolViolationException::class);
41
        Assert::validURI($content, SchemaViolationException::class);
42
    }
43
}
44