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

StringElementTrait::validateContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 11
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML;
6
7
use SimpleSAML\Assert\Assert;
8
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
9
use SimpleSAML\XML\StringElementTrait as BaseStringElementTrait;
10
11
/**
12
 * Trait extending the default StringElementTrait to comply with the restrictions added by the SAML 2.0 specifications.
13
 *
14
 * @package simplesamlphp/saml2
15
 */
16
trait StringElementTrait
17
{
18
    use BaseStringElementTrait;
19
20
    /**
21
     * Validate the content of the element.
22
     *
23
     * @param string $content  The value to go in the XML textContent
24
     * @throws \Exception on failure
25
     * @return void
26
     */
27
    protected function validateContent(/** @scrutinizer ignore-unused */ string $content): void
28
    {
29
        /**
30
         * 1.3.1 String Values
31
         *
32
         * All SAML string values have the type xs:string, which is built in to the W3C XML Schema Datatypes
33
         * specification [Schema2]. Unless otherwise noted in this specification or particular profiles, all strings in
34
         * SAML messages MUST consist of at least one non-whitespace character (whitespace is defined in the
35
         * XML Recommendation [XML] Section 2.3).
36
         */
37
        Assert::notWhitespaceOnly($content, ProtocolViolationException::class);
38
    }
39
}
40