1 | <?php |
||
18 | class Integer extends Element |
||
19 | { |
||
20 | use UniversalClass; |
||
21 | use PrimitiveType; |
||
22 | |||
23 | /** |
||
24 | * The number. |
||
25 | * |
||
26 | * @var BigInt |
||
27 | */ |
||
28 | private $_number; |
||
29 | |||
30 | /** |
||
31 | * Constructor. |
||
32 | * |
||
33 | * @param int|string $number Base 10 integer |
||
34 | */ |
||
35 | 58 | public function __construct($number) |
|
44 | |||
45 | /** |
||
46 | * Get the number as a base 10. |
||
47 | * |
||
48 | * @return string Integer as a string |
||
49 | */ |
||
50 | 24 | public function number(): string |
|
54 | |||
55 | /** |
||
56 | * Get the number as an integer type. |
||
57 | * |
||
58 | * @return int |
||
59 | */ |
||
60 | 2 | public function intNumber(): int |
|
64 | |||
65 | /** |
||
66 | * |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | 27 | protected function _encodedContentDER(): string |
|
83 | |||
84 | /** |
||
85 | * Encode positive integer to DER content. |
||
86 | * |
||
87 | * @param \GMP|resource $num |
||
88 | * @return string |
||
89 | */ |
||
90 | 10 | private static function _encodePositiveInteger(\GMP $num): string |
|
100 | |||
101 | /** |
||
102 | * Encode negative integer to DER content. |
||
103 | * |
||
104 | * @param \GMP|resource $num |
||
105 | * @return string |
||
106 | */ |
||
107 | 15 | private static function _encodeNegativeInteger(\GMP $num): string |
|
129 | |||
130 | /** |
||
131 | * |
||
132 | * {@inheritdoc} |
||
133 | * @return self |
||
134 | */ |
||
135 | 29 | protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
160 | |||
161 | /** |
||
162 | * Test that number is valid for this context. |
||
163 | * |
||
164 | * @param mixed $num |
||
165 | * @return bool |
||
166 | */ |
||
167 | 58 | private static function _validateNumber($num): bool |
|
177 | } |
||
178 |