Passed
Push — master ( a92056...ea57c8 )
by Tim
06:07 queued 03:34
created

DomainHint::validateContent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\XML\mdui;
6
7
use DOMElement;
8
use SimpleSAML\Assert\Assert;
9
use SimpleSAML\SAML2\Exception\InvalidArgumentException;
10
use SimpleSAML\XML\XMLStringElementTrait;
11
12
/**
13
 * Class implementing DomainHint.
14
 *
15
 * @package simplesamlphp/saml2
16
 */
17
final class DomainHint extends AbstractMduiElement
18
{
19
    use XMLStringElementTrait;
0 ignored issues
show
introduced by
The trait SimpleSAML\XML\XMLStringElementTrait requires some properties which are not provided by SimpleSAML\SAML2\XML\mdui\DomainHint: $localName, $namespaceURI
Loading history...
20
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
        Assert::notEmpty($content, 'DomainHint cannot be empty');
32
33
        if (!filter_var($content, FILTER_VALIDATE_DOMAIN)) {
34
            throw new InvalidArgumentException('DomainHint is not a valid hostname.');
35
        }
36
    }
37
}
38