Passed
Pull Request — master (#55)
by Tim
01:51
created

IDRefTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validIDRef() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XML\Assert;
6
7
use InvalidArgumentException;
8
9
/**
10
 * @package simplesamlphp/xml-common
11
 */
12
trait IDRefTrait
13
{
14
    /***********************************************************************************
15
     *  NOTE:  Custom assertions may be added below this line.                         *
16
     *         They SHOULD be marked as `protected` to ensure the call is forced       *
17
     *          through __callStatic().                                                *
18
     *         Assertions marked `public` are called directly and will                 *
19
     *          not handle any custom exception passed to it.                          *
20
     ***********************************************************************************/
21
22
23
    /**
24
     * @param string $value
25
     * @param string $message
26
     */
27
    protected static function validIDRef(string $value, string $message = ''): void
28
    {
29
        Assert::validNCName(
30
            $value,
31
            $message ?: '\'%s\' is not a xs:IDREF',
32
            InvalidArgumentException::class,
33
        );
34
    }
35
}
36