-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathLongTrait.php
More file actions
60 lines (54 loc) · 1.47 KB
/
LongTrait.php
File metadata and controls
60 lines (54 loc) · 1.47 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
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace SimpleSAML\XML\Assert;
use InvalidArgumentException;
/**
* @package simplesamlphp/xml-common
*/
trait LongTrait
{
private static string $long_regex = '/^
(
([-+]?[0]*)?
(?:
[1-9]
|[1-9]\d{1,14}
|1000000000000000
|1000000000000000[1-9]
|10000000000000000[1-9]
|[1-8][1-9]\d{17}
|9[01]\d{17}
|92[01]\d{16}
|922[0-2]\d{15}
|9223[0-2]\d{14}
|92233[0-6]\d{13}
|922337[01]\d{12}
|92233720[0-2]\d{10}
|922337203[0-5]\d{9}
|9223372036[0-7]\d{8}
|92233720368[0-4]\d{7}
|922337203685[0-3]\d{6}
|9223372036854[0-6]\d{5}
|92233720368547[0-6]\d{4}
|922337203685477[0-4]\d{3}
|9223372036854775[0-7]\d{2}
|922337203685477580[0-7]
)
|0
|(-([0]*)?)9223372036854775808
)
$/Dx';
/**
* @param string $value
* @param string $message
*/
protected static function validLong(string $value, string $message = ''): void
{
parent::regex(
$value,
self::$long_regex,
$message ?: '%s is not a valid xs:long',
InvalidArgumentException::class,
);
}
}