Passed
Pull Request — master (#60)
by Tim
02:12
created

KeySizeTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validKeySize() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Assert;
6
7
use InvalidArgumentException;
8
9
/**
10
 * @package simplesamlphp/xml-security
11
 */
12
trait KeySizeTrait
13
{
14
    /**
15
     * The size in bits of the key to be derived from the shared secret as the UTF-8 string for the corresponding
16
     * decimal integer with only digits in the string and no leading zeros.
17
     *
18
     * @var string
19
     */
20
    private static string $keySize_regex = '/^([1-9]\d*)$/D';
21
22
23
    /**
24
     * @param string $value
25
     * @param string $message
26
     */
27
    protected static function validKeySize(string $value, string $message = ''): void
28
    {
29
        parent::regex(
30
            $value,
31
            self::$keySize_regex,
32
            $message ?: '%s is not a valid xenc:keySizeType',
33
            InvalidArgumentException::class,
34
        );
35
    }
36
}
37