DomainTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A validDomain() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\Assert;
6
7
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
8
9
/**
10
 * @package simplesamlphp/saml2
11
 */
12
trait DomainTrait
13
{
14
    private static string $domain_regex = '/^
15
      (?!\-)
16
      (?:(?:[a-zA-Z\d][a-zA-Z\d\-]{0,61})?[a-zA-Z\d]\.){0,126}
17
      (?!\d+)[a-zA-Z\d]{1,63}
18
      $/Dxi';
19
20
21
    /**
22
     */
23
    protected static function validDomain(string $value, string $message = ''): void
24
    {
25
        parent::regex(
26
            $value,
27
            self::$domain_regex,
28
            $message ?: '%s is not a valid domain name',
29
            ProtocolViolationException::class,
30
        );
31
    }
32
}
33