-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathByteTrait.php
More file actions
53 lines (47 loc) · 1.11 KB
/
ByteTrait.php
File metadata and controls
53 lines (47 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
namespace SimpleSAML\XML\Assert;
use InvalidArgumentException;
/**
* @package simplesamlphp/xml-common
*/
trait ByteTrait
{
private static string $byte_regex = '/^
(
(
(
-[0]*
(
[0-9]
|[1-8]\d
|9\d
|1[01]\d
|12[0-8]
)
)|(
[+]?[0]*
(
[0-9]
|[1-8]\d
|9\d
|1[01]\d
|12[0-7]
)
)|0
)
)$/Dx';
/**
* @param string $value
* @param string $message
*/
protected static function validByte(string $value, string $message = ''): void
{
parent::regex(
$value,
self::$byte_regex,
$message ?: '%s is not a valid xs:byte',
InvalidArgumentException::class,
);
}
}