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

GeolocationHint::validateContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 4
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\XML\XMLStringElementTrait;
10
11
/**
12
 * Class implementing GeolocationHint.
13
 *
14
 * @package simplesamlphp/saml2
15
 */
16
final class GeolocationHint extends AbstractMduiElement
17
{
18
    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\GeolocationHint: $localName, $namespaceURI
Loading history...
19
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
        Assert::notEmpty($content, 'GeolocationHint cannot be empty');
31
        Assert::regex($content, '/^geo:([-+]?\d+(?:\.\d+)?),([-+]?\d+(?:\.\d+)?)(?:\?z=(\d{1,2}))?$/', 'Content is not a valid geolocation');
32
    }
33
}
34