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

KeySizeTrait::validKeySize()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 1
nop 2
dl 0
loc 7
rs 10
c 1
b 0
f 0
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