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

StringElementTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateContent() 0 11 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\StringElementTrait as BaseStringElementTrait;
10
11
/**
12
 * Trait extending the default StringElementTrait to comply with the restrictions added by the SAML 1.1 specifications.
13
 *
14
 * @package simplesamlphp/saml11
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.2.1 String and URI Values
31
         *
32
         * All SAML string and URI reference values have the types xsd:string and xsd:anyURI respectively, which
33
         * are built in to the W3C XML Schema Datatypes specification [Schema2]. All strings in SAML messages
34
         * MUST consist of at least one non-whitespace character (whitespace is defined in the XML
35
         * Recommendation [XML] §2.3). Empty and whitespace-only values are disallowed.
36
         */
37
        Assert::notWhitespaceOnly($content, ProtocolViolationException::class);
38
    }
39
}
40