@@ -15,29 +15,29 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class BMPString extends PrimitiveString |
| 17 | 17 | { |
| 18 | - use UniversalClass; |
|
| 18 | + use UniversalClass; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Constructor. |
|
| 22 | - * |
|
| 23 | - * @param string $string |
|
| 24 | - */ |
|
| 25 | - public function __construct(string $string) |
|
| 26 | - { |
|
| 27 | - $this->_typeTag = self::TYPE_BMP_STRING; |
|
| 28 | - parent::__construct($string); |
|
| 29 | - } |
|
| 20 | + /** |
|
| 21 | + * Constructor. |
|
| 22 | + * |
|
| 23 | + * @param string $string |
|
| 24 | + */ |
|
| 25 | + public function __construct(string $string) |
|
| 26 | + { |
|
| 27 | + $this->_typeTag = self::TYPE_BMP_STRING; |
|
| 28 | + parent::__construct($string); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * |
|
| 33 | - * {@inheritdoc} |
|
| 34 | - */ |
|
| 35 | - protected function _validateString(string $string): bool |
|
| 36 | - { |
|
| 37 | - // UCS-2 has fixed with of 2 octets (16 bits) |
|
| 38 | - if (strlen($string) % 2 !== 0) { |
|
| 39 | - return false; |
|
| 40 | - } |
|
| 41 | - return true; |
|
| 42 | - } |
|
| 31 | + /** |
|
| 32 | + * |
|
| 33 | + * {@inheritdoc} |
|
| 34 | + */ |
|
| 35 | + protected function _validateString(string $string): bool |
|
| 36 | + { |
|
| 37 | + // UCS-2 has fixed with of 2 octets (16 bits) |
|
| 38 | + if (strlen($string) % 2 !== 0) { |
|
| 39 | + return false; |
|
| 40 | + } |
|
| 41 | + return true; |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -14,29 +14,29 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class UniversalString extends PrimitiveString |
| 16 | 16 | { |
| 17 | - use UniversalClass; |
|
| 17 | + use UniversalClass; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Constructor. |
|
| 21 | - * |
|
| 22 | - * @param string $string |
|
| 23 | - */ |
|
| 24 | - public function __construct(string $string) |
|
| 25 | - { |
|
| 26 | - $this->_typeTag = self::TYPE_UNIVERSAL_STRING; |
|
| 27 | - parent::__construct($string); |
|
| 28 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor. |
|
| 21 | + * |
|
| 22 | + * @param string $string |
|
| 23 | + */ |
|
| 24 | + public function __construct(string $string) |
|
| 25 | + { |
|
| 26 | + $this->_typeTag = self::TYPE_UNIVERSAL_STRING; |
|
| 27 | + parent::__construct($string); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * |
|
| 32 | - * {@inheritdoc} |
|
| 33 | - */ |
|
| 34 | - protected function _validateString(string $string): bool |
|
| 35 | - { |
|
| 36 | - // UCS-4 has fixed with of 4 octets (32 bits) |
|
| 37 | - if (strlen($string) % 4 != 0) { |
|
| 38 | - return false; |
|
| 39 | - } |
|
| 40 | - return true; |
|
| 41 | - } |
|
| 30 | + /** |
|
| 31 | + * |
|
| 32 | + * {@inheritdoc} |
|
| 33 | + */ |
|
| 34 | + protected function _validateString(string $string): bool |
|
| 35 | + { |
|
| 36 | + // UCS-4 has fixed with of 4 octets (32 bits) |
|
| 37 | + if (strlen($string) % 4 != 0) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | + return true; |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -14,25 +14,25 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class UTF8String extends PrimitiveString |
| 16 | 16 | { |
| 17 | - use UniversalClass; |
|
| 17 | + use UniversalClass; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Constructor. |
|
| 21 | - * |
|
| 22 | - * @param string $string |
|
| 23 | - */ |
|
| 24 | - public function __construct(string $string) |
|
| 25 | - { |
|
| 26 | - $this->_typeTag = self::TYPE_UTF8_STRING; |
|
| 27 | - parent::__construct($string); |
|
| 28 | - } |
|
| 19 | + /** |
|
| 20 | + * Constructor. |
|
| 21 | + * |
|
| 22 | + * @param string $string |
|
| 23 | + */ |
|
| 24 | + public function __construct(string $string) |
|
| 25 | + { |
|
| 26 | + $this->_typeTag = self::TYPE_UTF8_STRING; |
|
| 27 | + parent::__construct($string); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * |
|
| 32 | - * {@inheritdoc} |
|
| 33 | - */ |
|
| 34 | - protected function _validateString(string $string): bool |
|
| 35 | - { |
|
| 36 | - return mb_check_encoding($string, "UTF-8"); |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * |
|
| 32 | + * {@inheritdoc} |
|
| 33 | + */ |
|
| 34 | + protected function _validateString(string $string): bool |
|
| 35 | + { |
|
| 36 | + return mb_check_encoding($string, "UTF-8"); |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -12,27 +12,27 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class T61String extends PrimitiveString |
| 14 | 14 | { |
| 15 | - use UniversalClass; |
|
| 15 | + use UniversalClass; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Constructor. |
|
| 19 | - * |
|
| 20 | - * @param string $string |
|
| 21 | - */ |
|
| 22 | - public function __construct(string $string) |
|
| 23 | - { |
|
| 24 | - $this->_typeTag = self::TYPE_T61_STRING; |
|
| 25 | - parent::__construct($string); |
|
| 26 | - } |
|
| 17 | + /** |
|
| 18 | + * Constructor. |
|
| 19 | + * |
|
| 20 | + * @param string $string |
|
| 21 | + */ |
|
| 22 | + public function __construct(string $string) |
|
| 23 | + { |
|
| 24 | + $this->_typeTag = self::TYPE_T61_STRING; |
|
| 25 | + parent::__construct($string); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * |
|
| 30 | - * {@inheritdoc} |
|
| 31 | - */ |
|
| 32 | - protected function _validateString(string $string): bool |
|
| 33 | - { |
|
| 34 | - // allow everything since there's literally |
|
| 35 | - // thousands of allowed characters (16 bit composed characters) |
|
| 36 | - return true; |
|
| 37 | - } |
|
| 28 | + /** |
|
| 29 | + * |
|
| 30 | + * {@inheritdoc} |
|
| 31 | + */ |
|
| 32 | + protected function _validateString(string $string): bool |
|
| 33 | + { |
|
| 34 | + // allow everything since there's literally |
|
| 35 | + // thousands of allowed characters (16 bit composed characters) |
|
| 36 | + return true; |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -12,25 +12,25 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class VisibleString extends PrimitiveString |
| 14 | 14 | { |
| 15 | - use UniversalClass; |
|
| 15 | + use UniversalClass; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Constructor. |
|
| 19 | - * |
|
| 20 | - * @param string $string |
|
| 21 | - */ |
|
| 22 | - public function __construct(string $string) |
|
| 23 | - { |
|
| 24 | - $this->_typeTag = self::TYPE_VISIBLE_STRING; |
|
| 25 | - parent::__construct($string); |
|
| 26 | - } |
|
| 17 | + /** |
|
| 18 | + * Constructor. |
|
| 19 | + * |
|
| 20 | + * @param string $string |
|
| 21 | + */ |
|
| 22 | + public function __construct(string $string) |
|
| 23 | + { |
|
| 24 | + $this->_typeTag = self::TYPE_VISIBLE_STRING; |
|
| 25 | + parent::__construct($string); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * |
|
| 30 | - * {@inheritdoc} |
|
| 31 | - */ |
|
| 32 | - protected function _validateString(string $string): bool |
|
| 33 | - { |
|
| 34 | - return preg_match('/[^\x20-\x7e]/', $string) == 0; |
|
| 35 | - } |
|
| 28 | + /** |
|
| 29 | + * |
|
| 30 | + * {@inheritdoc} |
|
| 31 | + */ |
|
| 32 | + protected function _validateString(string $string): bool |
|
| 33 | + { |
|
| 34 | + return preg_match('/[^\x20-\x7e]/', $string) == 0; |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -12,26 +12,26 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class ObjectDescriptor extends PrimitiveString |
| 14 | 14 | { |
| 15 | - use UniversalClass; |
|
| 15 | + use UniversalClass; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Constructor. |
|
| 19 | - * |
|
| 20 | - * @param string $descriptor |
|
| 21 | - */ |
|
| 22 | - public function __construct(string $descriptor) |
|
| 23 | - { |
|
| 24 | - $this->_string = $descriptor; |
|
| 25 | - $this->_typeTag = self::TYPE_OBJECT_DESCRIPTOR; |
|
| 26 | - } |
|
| 17 | + /** |
|
| 18 | + * Constructor. |
|
| 19 | + * |
|
| 20 | + * @param string $descriptor |
|
| 21 | + */ |
|
| 22 | + public function __construct(string $descriptor) |
|
| 23 | + { |
|
| 24 | + $this->_string = $descriptor; |
|
| 25 | + $this->_typeTag = self::TYPE_OBJECT_DESCRIPTOR; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Get the object descriptor. |
|
| 30 | - * |
|
| 31 | - * @return string |
|
| 32 | - */ |
|
| 33 | - public function descriptor(): string |
|
| 34 | - { |
|
| 35 | - return $this->_string; |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * Get the object descriptor. |
|
| 30 | + * |
|
| 31 | + * @return string |
|
| 32 | + */ |
|
| 33 | + public function descriptor(): string |
|
| 34 | + { |
|
| 35 | + return $this->_string; |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -12,25 +12,25 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class NumericString extends PrimitiveString |
| 14 | 14 | { |
| 15 | - use UniversalClass; |
|
| 15 | + use UniversalClass; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Constructor. |
|
| 19 | - * |
|
| 20 | - * @param string $string |
|
| 21 | - */ |
|
| 22 | - public function __construct(string $string) |
|
| 23 | - { |
|
| 24 | - $this->_typeTag = self::TYPE_NUMERIC_STRING; |
|
| 25 | - parent::__construct($string); |
|
| 26 | - } |
|
| 17 | + /** |
|
| 18 | + * Constructor. |
|
| 19 | + * |
|
| 20 | + * @param string $string |
|
| 21 | + */ |
|
| 22 | + public function __construct(string $string) |
|
| 23 | + { |
|
| 24 | + $this->_typeTag = self::TYPE_NUMERIC_STRING; |
|
| 25 | + parent::__construct($string); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * |
|
| 30 | - * {@inheritdoc} |
|
| 31 | - */ |
|
| 32 | - protected function _validateString(string $string): bool |
|
| 33 | - { |
|
| 34 | - return preg_match('/[^0-9 ]/', $string) == 0; |
|
| 35 | - } |
|
| 28 | + /** |
|
| 29 | + * |
|
| 30 | + * {@inheritdoc} |
|
| 31 | + */ |
|
| 32 | + protected function _validateString(string $string): bool |
|
| 33 | + { |
|
| 34 | + return preg_match('/[^0-9 ]/', $string) == 0; |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | * {@inheritdoc} |
| 23 | 23 | */ |
| 24 | 24 | protected static function _decodeFromDER(Identifier $identifier, string $data, |
| 25 | - int &$offset): ElementBase |
|
| 25 | + int & $offset): ElementBase |
|
| 26 | 26 | { |
| 27 | 27 | $idx = $offset; |
| 28 | 28 | $type = new DERTaggedType($identifier, $data, $idx); |
@@ -17,85 +17,85 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | abstract class TaggedType extends Element |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * |
|
| 22 | - * {@inheritdoc} |
|
| 23 | - */ |
|
| 24 | - protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
| 25 | - int &$offset): ElementBase |
|
| 26 | - { |
|
| 27 | - $idx = $offset; |
|
| 28 | - $type = new DERTaggedType($identifier, $data, $idx); |
|
| 29 | - $length = Length::expectFromDER($data, $idx)->intLength(); |
|
| 30 | - $offset = $idx + $length; |
|
| 31 | - return $type; |
|
| 32 | - } |
|
| 20 | + /** |
|
| 21 | + * |
|
| 22 | + * {@inheritdoc} |
|
| 23 | + */ |
|
| 24 | + protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
| 25 | + int &$offset): ElementBase |
|
| 26 | + { |
|
| 27 | + $idx = $offset; |
|
| 28 | + $type = new DERTaggedType($identifier, $data, $idx); |
|
| 29 | + $length = Length::expectFromDER($data, $idx)->intLength(); |
|
| 30 | + $offset = $idx + $length; |
|
| 31 | + return $type; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Check whether element supports explicit tagging. |
|
| 36 | - * |
|
| 37 | - * @param int|null $expectedTag Optional outer tag expectation |
|
| 38 | - * @throws \UnexpectedValueException If expectation fails |
|
| 39 | - * @return ExplicitTagging |
|
| 40 | - */ |
|
| 41 | - public function expectExplicit($expectedTag = null): ExplicitTagging |
|
| 42 | - { |
|
| 43 | - $el = $this; |
|
| 44 | - if (!$el instanceof ExplicitTagging) { |
|
| 45 | - throw new \UnexpectedValueException( |
|
| 46 | - "Element doesn't implement explicit tagging."); |
|
| 47 | - } |
|
| 48 | - if (isset($expectedTag)) { |
|
| 49 | - $el->expectTagged($expectedTag); |
|
| 50 | - } |
|
| 51 | - return $el; |
|
| 52 | - } |
|
| 34 | + /** |
|
| 35 | + * Check whether element supports explicit tagging. |
|
| 36 | + * |
|
| 37 | + * @param int|null $expectedTag Optional outer tag expectation |
|
| 38 | + * @throws \UnexpectedValueException If expectation fails |
|
| 39 | + * @return ExplicitTagging |
|
| 40 | + */ |
|
| 41 | + public function expectExplicit($expectedTag = null): ExplicitTagging |
|
| 42 | + { |
|
| 43 | + $el = $this; |
|
| 44 | + if (!$el instanceof ExplicitTagging) { |
|
| 45 | + throw new \UnexpectedValueException( |
|
| 46 | + "Element doesn't implement explicit tagging."); |
|
| 47 | + } |
|
| 48 | + if (isset($expectedTag)) { |
|
| 49 | + $el->expectTagged($expectedTag); |
|
| 50 | + } |
|
| 51 | + return $el; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Get the wrapped inner element employing explicit tagging. |
|
| 56 | - * |
|
| 57 | - * @param int|null $expectedTag Optional outer tag expectation |
|
| 58 | - * @throws \UnexpectedValueException If expectation fails |
|
| 59 | - * @return UnspecifiedType |
|
| 60 | - */ |
|
| 61 | - public function asExplicit($expectedTag = null): UnspecifiedType |
|
| 62 | - { |
|
| 63 | - return $this->expectExplicit($expectedTag)->explicit(); |
|
| 64 | - } |
|
| 54 | + /** |
|
| 55 | + * Get the wrapped inner element employing explicit tagging. |
|
| 56 | + * |
|
| 57 | + * @param int|null $expectedTag Optional outer tag expectation |
|
| 58 | + * @throws \UnexpectedValueException If expectation fails |
|
| 59 | + * @return UnspecifiedType |
|
| 60 | + */ |
|
| 61 | + public function asExplicit($expectedTag = null): UnspecifiedType |
|
| 62 | + { |
|
| 63 | + return $this->expectExplicit($expectedTag)->explicit(); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Check whether element supports implicit tagging. |
|
| 68 | - * |
|
| 69 | - * @param int|null $expectedTag Optional outer tag expectation |
|
| 70 | - * @throws \UnexpectedValueException If expectation fails |
|
| 71 | - * @return ImplicitTagging |
|
| 72 | - */ |
|
| 73 | - public function expectImplicit($expectedTag = null): ImplicitTagging |
|
| 74 | - { |
|
| 75 | - $el = $this; |
|
| 76 | - if (!$el instanceof ImplicitTagging) { |
|
| 77 | - throw new \UnexpectedValueException( |
|
| 78 | - "Element doesn't implement implicit tagging."); |
|
| 79 | - } |
|
| 80 | - if (isset($expectedTag)) { |
|
| 81 | - $el->expectTagged($expectedTag); |
|
| 82 | - } |
|
| 83 | - return $el; |
|
| 84 | - } |
|
| 66 | + /** |
|
| 67 | + * Check whether element supports implicit tagging. |
|
| 68 | + * |
|
| 69 | + * @param int|null $expectedTag Optional outer tag expectation |
|
| 70 | + * @throws \UnexpectedValueException If expectation fails |
|
| 71 | + * @return ImplicitTagging |
|
| 72 | + */ |
|
| 73 | + public function expectImplicit($expectedTag = null): ImplicitTagging |
|
| 74 | + { |
|
| 75 | + $el = $this; |
|
| 76 | + if (!$el instanceof ImplicitTagging) { |
|
| 77 | + throw new \UnexpectedValueException( |
|
| 78 | + "Element doesn't implement implicit tagging."); |
|
| 79 | + } |
|
| 80 | + if (isset($expectedTag)) { |
|
| 81 | + $el->expectTagged($expectedTag); |
|
| 82 | + } |
|
| 83 | + return $el; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Get the wrapped inner element employing implicit tagging. |
|
| 88 | - * |
|
| 89 | - * @param int $tag Type tag of the inner element |
|
| 90 | - * @param int|null $expectedTag Optional outer tag expectation |
|
| 91 | - * @param int $expectedClass Optional inner type class expectation |
|
| 92 | - * @throws \UnexpectedValueException If expectation fails |
|
| 93 | - * @return UnspecifiedType |
|
| 94 | - */ |
|
| 95 | - public function asImplicit(int $tag, $expectedTag = null, |
|
| 96 | - int $expectedClass = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
| 97 | - { |
|
| 98 | - return $this->expectImplicit($expectedTag)->implicit($tag, |
|
| 99 | - $expectedClass); |
|
| 100 | - } |
|
| 86 | + /** |
|
| 87 | + * Get the wrapped inner element employing implicit tagging. |
|
| 88 | + * |
|
| 89 | + * @param int $tag Type tag of the inner element |
|
| 90 | + * @param int|null $expectedTag Optional outer tag expectation |
|
| 91 | + * @param int $expectedClass Optional inner type class expectation |
|
| 92 | + * @throws \UnexpectedValueException If expectation fails |
|
| 93 | + * @return UnspecifiedType |
|
| 94 | + */ |
|
| 95 | + public function asImplicit(int $tag, $expectedTag = null, |
|
| 96 | + int $expectedClass = Identifier::CLASS_UNIVERSAL): UnspecifiedType |
|
| 97 | + { |
|
| 98 | + return $this->expectImplicit($expectedTag)->implicit($tag, |
|
| 99 | + $expectedClass); |
|
| 100 | + } |
|
| 101 | 101 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @return self |
| 92 | 92 | */ |
| 93 | 93 | protected static function _decodeFromDER(Identifier $identifier, string $data, |
| 94 | - int &$offset): ElementBase |
|
| 94 | + int & $offset): ElementBase |
|
| 95 | 95 | { |
| 96 | 96 | $idx = $offset; |
| 97 | 97 | if (!$identifier->isConstructed()) { |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | { |
| 237 | 237 | if (!isset($this->_unspecifiedTypes)) { |
| 238 | 238 | $this->_unspecifiedTypes = array_map( |
| 239 | - function (Element $el) { |
|
| 239 | + function(Element $el) { |
|
| 240 | 240 | return new UnspecifiedType($el); |
| 241 | 241 | }, $this->_elements); |
| 242 | 242 | } |
@@ -14,336 +14,336 @@ |
||
| 14 | 14 | * Base class for the constructed types. |
| 15 | 15 | */ |
| 16 | 16 | abstract class Structure extends Element implements |
| 17 | - \Countable, |
|
| 18 | - \IteratorAggregate |
|
| 17 | + \Countable, |
|
| 18 | + \IteratorAggregate |
|
| 19 | 19 | { |
| 20 | - use UniversalClass; |
|
| 20 | + use UniversalClass; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Array of elements in the structure. |
|
| 24 | - * |
|
| 25 | - * @var Element[] $_elements |
|
| 26 | - */ |
|
| 27 | - protected $_elements; |
|
| 22 | + /** |
|
| 23 | + * Array of elements in the structure. |
|
| 24 | + * |
|
| 25 | + * @var Element[] $_elements |
|
| 26 | + */ |
|
| 27 | + protected $_elements; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Lookup table for the tagged elements. |
|
| 31 | - * |
|
| 32 | - * @var TaggedType[]|null $_taggedMap |
|
| 33 | - */ |
|
| 34 | - private $_taggedMap; |
|
| 29 | + /** |
|
| 30 | + * Lookup table for the tagged elements. |
|
| 31 | + * |
|
| 32 | + * @var TaggedType[]|null $_taggedMap |
|
| 33 | + */ |
|
| 34 | + private $_taggedMap; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Cache variable of elements wrapped into UnspecifiedType objects. |
|
| 38 | - * |
|
| 39 | - * @var UnspecifiedType[]|null $_unspecifiedTypes |
|
| 40 | - */ |
|
| 41 | - private $_unspecifiedTypes; |
|
| 36 | + /** |
|
| 37 | + * Cache variable of elements wrapped into UnspecifiedType objects. |
|
| 38 | + * |
|
| 39 | + * @var UnspecifiedType[]|null $_unspecifiedTypes |
|
| 40 | + */ |
|
| 41 | + private $_unspecifiedTypes; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Constructor. |
|
| 45 | - * |
|
| 46 | - * @param Element ...$elements Any number of elements |
|
| 47 | - */ |
|
| 48 | - public function __construct(Element ...$elements) |
|
| 49 | - { |
|
| 50 | - $this->_elements = $elements; |
|
| 51 | - } |
|
| 43 | + /** |
|
| 44 | + * Constructor. |
|
| 45 | + * |
|
| 46 | + * @param Element ...$elements Any number of elements |
|
| 47 | + */ |
|
| 48 | + public function __construct(Element ...$elements) |
|
| 49 | + { |
|
| 50 | + $this->_elements = $elements; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Clone magic method. |
|
| 55 | - */ |
|
| 56 | - public function __clone() |
|
| 57 | - { |
|
| 58 | - // clear cache-variables |
|
| 59 | - $this->_taggedMap = null; |
|
| 60 | - $this->_unspecifiedTypes = null; |
|
| 61 | - } |
|
| 53 | + /** |
|
| 54 | + * Clone magic method. |
|
| 55 | + */ |
|
| 56 | + public function __clone() |
|
| 57 | + { |
|
| 58 | + // clear cache-variables |
|
| 59 | + $this->_taggedMap = null; |
|
| 60 | + $this->_unspecifiedTypes = null; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * |
|
| 65 | - * @see \ASN1\Element::isConstructed() |
|
| 66 | - * @return bool |
|
| 67 | - */ |
|
| 68 | - public function isConstructed(): bool |
|
| 69 | - { |
|
| 70 | - return true; |
|
| 71 | - } |
|
| 63 | + /** |
|
| 64 | + * |
|
| 65 | + * @see \ASN1\Element::isConstructed() |
|
| 66 | + * @return bool |
|
| 67 | + */ |
|
| 68 | + public function isConstructed(): bool |
|
| 69 | + { |
|
| 70 | + return true; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * |
|
| 75 | - * @see \ASN1\Element::_encodedContentDER() |
|
| 76 | - * @return string |
|
| 77 | - */ |
|
| 78 | - protected function _encodedContentDER(): string |
|
| 79 | - { |
|
| 80 | - $data = ""; |
|
| 81 | - foreach ($this->_elements as $element) { |
|
| 82 | - $data .= $element->toDER(); |
|
| 83 | - } |
|
| 84 | - return $data; |
|
| 85 | - } |
|
| 73 | + /** |
|
| 74 | + * |
|
| 75 | + * @see \ASN1\Element::_encodedContentDER() |
|
| 76 | + * @return string |
|
| 77 | + */ |
|
| 78 | + protected function _encodedContentDER(): string |
|
| 79 | + { |
|
| 80 | + $data = ""; |
|
| 81 | + foreach ($this->_elements as $element) { |
|
| 82 | + $data .= $element->toDER(); |
|
| 83 | + } |
|
| 84 | + return $data; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * |
|
| 89 | - * {@inheritdoc} |
|
| 90 | - * @see \ASN1\Element::_decodeFromDER() |
|
| 91 | - * @return self |
|
| 92 | - */ |
|
| 93 | - protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
| 94 | - int &$offset): ElementBase |
|
| 95 | - { |
|
| 96 | - $idx = $offset; |
|
| 97 | - if (!$identifier->isConstructed()) { |
|
| 98 | - throw new DecodeException( |
|
| 99 | - "Structured element must have constructed bit set."); |
|
| 100 | - } |
|
| 101 | - $length = Length::expectFromDER($data, $idx); |
|
| 102 | - $end = $idx + $length->intLength(); |
|
| 103 | - $elements = []; |
|
| 104 | - while ($idx < $end) { |
|
| 105 | - $elements[] = Element::fromDER($data, $idx); |
|
| 106 | - // check that element didn't overflow length |
|
| 107 | - if ($idx > $end) { |
|
| 108 | - throw new DecodeException( |
|
| 109 | - "Structure's content overflows length."); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - $offset = $idx; |
|
| 113 | - // return instance by static late binding |
|
| 114 | - return new static(...$elements); |
|
| 115 | - } |
|
| 87 | + /** |
|
| 88 | + * |
|
| 89 | + * {@inheritdoc} |
|
| 90 | + * @see \ASN1\Element::_decodeFromDER() |
|
| 91 | + * @return self |
|
| 92 | + */ |
|
| 93 | + protected static function _decodeFromDER(Identifier $identifier, string $data, |
|
| 94 | + int &$offset): ElementBase |
|
| 95 | + { |
|
| 96 | + $idx = $offset; |
|
| 97 | + if (!$identifier->isConstructed()) { |
|
| 98 | + throw new DecodeException( |
|
| 99 | + "Structured element must have constructed bit set."); |
|
| 100 | + } |
|
| 101 | + $length = Length::expectFromDER($data, $idx); |
|
| 102 | + $end = $idx + $length->intLength(); |
|
| 103 | + $elements = []; |
|
| 104 | + while ($idx < $end) { |
|
| 105 | + $elements[] = Element::fromDER($data, $idx); |
|
| 106 | + // check that element didn't overflow length |
|
| 107 | + if ($idx > $end) { |
|
| 108 | + throw new DecodeException( |
|
| 109 | + "Structure's content overflows length."); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + $offset = $idx; |
|
| 113 | + // return instance by static late binding |
|
| 114 | + return new static(...$elements); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * Explode DER structure to DER encoded components that it contains. |
|
| 119 | - * |
|
| 120 | - * @param string $data |
|
| 121 | - * @throws DecodeException |
|
| 122 | - * @return string[] |
|
| 123 | - */ |
|
| 124 | - public static function explodeDER(string $data): array |
|
| 125 | - { |
|
| 126 | - $offset = 0; |
|
| 127 | - $identifier = Identifier::fromDER($data, $offset); |
|
| 128 | - if (!$identifier->isConstructed()) { |
|
| 129 | - throw new DecodeException("Element is not constructed."); |
|
| 130 | - } |
|
| 131 | - $length = Length::expectFromDER($data, $offset)->intLength(); |
|
| 132 | - $end = $offset + $length; |
|
| 133 | - $parts = []; |
|
| 134 | - while ($offset < $end) { |
|
| 135 | - // start of the element |
|
| 136 | - $idx = $offset; |
|
| 137 | - // skip identifier |
|
| 138 | - Identifier::fromDER($data, $offset); |
|
| 139 | - // decode element length |
|
| 140 | - $length = Length::expectFromDER($data, $offset)->intLength(); |
|
| 141 | - // extract der encoding of the element |
|
| 142 | - $parts[] = substr($data, $idx, $offset - $idx + $length); |
|
| 143 | - // update offset over content |
|
| 144 | - $offset += $length; |
|
| 145 | - } |
|
| 146 | - return $parts; |
|
| 147 | - } |
|
| 117 | + /** |
|
| 118 | + * Explode DER structure to DER encoded components that it contains. |
|
| 119 | + * |
|
| 120 | + * @param string $data |
|
| 121 | + * @throws DecodeException |
|
| 122 | + * @return string[] |
|
| 123 | + */ |
|
| 124 | + public static function explodeDER(string $data): array |
|
| 125 | + { |
|
| 126 | + $offset = 0; |
|
| 127 | + $identifier = Identifier::fromDER($data, $offset); |
|
| 128 | + if (!$identifier->isConstructed()) { |
|
| 129 | + throw new DecodeException("Element is not constructed."); |
|
| 130 | + } |
|
| 131 | + $length = Length::expectFromDER($data, $offset)->intLength(); |
|
| 132 | + $end = $offset + $length; |
|
| 133 | + $parts = []; |
|
| 134 | + while ($offset < $end) { |
|
| 135 | + // start of the element |
|
| 136 | + $idx = $offset; |
|
| 137 | + // skip identifier |
|
| 138 | + Identifier::fromDER($data, $offset); |
|
| 139 | + // decode element length |
|
| 140 | + $length = Length::expectFromDER($data, $offset)->intLength(); |
|
| 141 | + // extract der encoding of the element |
|
| 142 | + $parts[] = substr($data, $idx, $offset - $idx + $length); |
|
| 143 | + // update offset over content |
|
| 144 | + $offset += $length; |
|
| 145 | + } |
|
| 146 | + return $parts; |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * Get self with an element at the given index replaced by another. |
|
| 151 | - * |
|
| 152 | - * @param int $idx Element index |
|
| 153 | - * @param Element $el New element to insert into the structure |
|
| 154 | - * @throws \OutOfBoundsException |
|
| 155 | - * @return self |
|
| 156 | - */ |
|
| 157 | - public function withReplaced(int $idx, Element $el): self |
|
| 158 | - { |
|
| 159 | - if (!isset($this->_elements[$idx])) { |
|
| 160 | - throw new \OutOfBoundsException( |
|
| 161 | - "Structure doesn't have element at index $idx."); |
|
| 162 | - } |
|
| 163 | - $obj = clone $this; |
|
| 164 | - $obj->_elements[$idx] = $el; |
|
| 165 | - return $obj; |
|
| 166 | - } |
|
| 149 | + /** |
|
| 150 | + * Get self with an element at the given index replaced by another. |
|
| 151 | + * |
|
| 152 | + * @param int $idx Element index |
|
| 153 | + * @param Element $el New element to insert into the structure |
|
| 154 | + * @throws \OutOfBoundsException |
|
| 155 | + * @return self |
|
| 156 | + */ |
|
| 157 | + public function withReplaced(int $idx, Element $el): self |
|
| 158 | + { |
|
| 159 | + if (!isset($this->_elements[$idx])) { |
|
| 160 | + throw new \OutOfBoundsException( |
|
| 161 | + "Structure doesn't have element at index $idx."); |
|
| 162 | + } |
|
| 163 | + $obj = clone $this; |
|
| 164 | + $obj->_elements[$idx] = $el; |
|
| 165 | + return $obj; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Get self with an element inserted before the given index. |
|
| 170 | - * |
|
| 171 | - * @param int $idx Element index |
|
| 172 | - * @param Element $el New element to insert into the structure |
|
| 173 | - * @throws \OutOfBoundsException |
|
| 174 | - * @return self |
|
| 175 | - */ |
|
| 176 | - public function withInserted(int $idx, Element $el): self |
|
| 177 | - { |
|
| 178 | - if (count($this->_elements) < $idx || $idx < 0) { |
|
| 179 | - throw new \OutOfBoundsException("Index $idx is out of bounds."); |
|
| 180 | - } |
|
| 181 | - $obj = clone $this; |
|
| 182 | - array_splice($obj->_elements, $idx, 0, [$el]); |
|
| 183 | - return $obj; |
|
| 184 | - } |
|
| 168 | + /** |
|
| 169 | + * Get self with an element inserted before the given index. |
|
| 170 | + * |
|
| 171 | + * @param int $idx Element index |
|
| 172 | + * @param Element $el New element to insert into the structure |
|
| 173 | + * @throws \OutOfBoundsException |
|
| 174 | + * @return self |
|
| 175 | + */ |
|
| 176 | + public function withInserted(int $idx, Element $el): self |
|
| 177 | + { |
|
| 178 | + if (count($this->_elements) < $idx || $idx < 0) { |
|
| 179 | + throw new \OutOfBoundsException("Index $idx is out of bounds."); |
|
| 180 | + } |
|
| 181 | + $obj = clone $this; |
|
| 182 | + array_splice($obj->_elements, $idx, 0, [$el]); |
|
| 183 | + return $obj; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * Get self with an element appended to the end. |
|
| 188 | - * |
|
| 189 | - * @param Element $el Element to insert into the structure |
|
| 190 | - * @return self |
|
| 191 | - */ |
|
| 192 | - public function withAppended(Element $el): self |
|
| 193 | - { |
|
| 194 | - $obj = clone $this; |
|
| 195 | - array_push($obj->_elements, $el); |
|
| 196 | - return $obj; |
|
| 197 | - } |
|
| 186 | + /** |
|
| 187 | + * Get self with an element appended to the end. |
|
| 188 | + * |
|
| 189 | + * @param Element $el Element to insert into the structure |
|
| 190 | + * @return self |
|
| 191 | + */ |
|
| 192 | + public function withAppended(Element $el): self |
|
| 193 | + { |
|
| 194 | + $obj = clone $this; |
|
| 195 | + array_push($obj->_elements, $el); |
|
| 196 | + return $obj; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * Get self with an element prepended in the beginning. |
|
| 201 | - * |
|
| 202 | - * @param Element $el Element to insert into the structure |
|
| 203 | - * @return self |
|
| 204 | - */ |
|
| 205 | - public function withPrepended(Element $el): self |
|
| 206 | - { |
|
| 207 | - $obj = clone $this; |
|
| 208 | - array_unshift($obj->_elements, $el); |
|
| 209 | - return $obj; |
|
| 210 | - } |
|
| 199 | + /** |
|
| 200 | + * Get self with an element prepended in the beginning. |
|
| 201 | + * |
|
| 202 | + * @param Element $el Element to insert into the structure |
|
| 203 | + * @return self |
|
| 204 | + */ |
|
| 205 | + public function withPrepended(Element $el): self |
|
| 206 | + { |
|
| 207 | + $obj = clone $this; |
|
| 208 | + array_unshift($obj->_elements, $el); |
|
| 209 | + return $obj; |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - /** |
|
| 213 | - * Get self with an element at the given index removed. |
|
| 214 | - * |
|
| 215 | - * @param int $idx Element index |
|
| 216 | - * @throws \OutOfBoundsException |
|
| 217 | - * @return self |
|
| 218 | - */ |
|
| 219 | - public function withoutElement(int $idx): self |
|
| 220 | - { |
|
| 221 | - if (!isset($this->_elements[$idx])) { |
|
| 222 | - throw new \OutOfBoundsException( |
|
| 223 | - "Structure doesn't have element at index $idx."); |
|
| 224 | - } |
|
| 225 | - $obj = clone $this; |
|
| 226 | - array_splice($obj->_elements, $idx, 1); |
|
| 227 | - return $obj; |
|
| 228 | - } |
|
| 212 | + /** |
|
| 213 | + * Get self with an element at the given index removed. |
|
| 214 | + * |
|
| 215 | + * @param int $idx Element index |
|
| 216 | + * @throws \OutOfBoundsException |
|
| 217 | + * @return self |
|
| 218 | + */ |
|
| 219 | + public function withoutElement(int $idx): self |
|
| 220 | + { |
|
| 221 | + if (!isset($this->_elements[$idx])) { |
|
| 222 | + throw new \OutOfBoundsException( |
|
| 223 | + "Structure doesn't have element at index $idx."); |
|
| 224 | + } |
|
| 225 | + $obj = clone $this; |
|
| 226 | + array_splice($obj->_elements, $idx, 1); |
|
| 227 | + return $obj; |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - /** |
|
| 231 | - * Get elements in the structure. |
|
| 232 | - * |
|
| 233 | - * @return UnspecifiedType[] |
|
| 234 | - */ |
|
| 235 | - public function elements(): array |
|
| 236 | - { |
|
| 237 | - if (!isset($this->_unspecifiedTypes)) { |
|
| 238 | - $this->_unspecifiedTypes = array_map( |
|
| 239 | - function (Element $el) { |
|
| 240 | - return new UnspecifiedType($el); |
|
| 241 | - }, $this->_elements); |
|
| 242 | - } |
|
| 243 | - return $this->_unspecifiedTypes; |
|
| 244 | - } |
|
| 230 | + /** |
|
| 231 | + * Get elements in the structure. |
|
| 232 | + * |
|
| 233 | + * @return UnspecifiedType[] |
|
| 234 | + */ |
|
| 235 | + public function elements(): array |
|
| 236 | + { |
|
| 237 | + if (!isset($this->_unspecifiedTypes)) { |
|
| 238 | + $this->_unspecifiedTypes = array_map( |
|
| 239 | + function (Element $el) { |
|
| 240 | + return new UnspecifiedType($el); |
|
| 241 | + }, $this->_elements); |
|
| 242 | + } |
|
| 243 | + return $this->_unspecifiedTypes; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - /** |
|
| 247 | - * Check whether the structure has an element at the given index, optionally |
|
| 248 | - * satisfying given tag expectation. |
|
| 249 | - * |
|
| 250 | - * @param int $idx Index 0..n |
|
| 251 | - * @param int|null $expectedTag Optional type tag expectation |
|
| 252 | - * @return bool |
|
| 253 | - */ |
|
| 254 | - public function has(int $idx, $expectedTag = null): bool |
|
| 255 | - { |
|
| 256 | - if (!isset($this->_elements[$idx])) { |
|
| 257 | - return false; |
|
| 258 | - } |
|
| 259 | - if (isset($expectedTag)) { |
|
| 260 | - if (!$this->_elements[$idx]->isType($expectedTag)) { |
|
| 261 | - return false; |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - return true; |
|
| 265 | - } |
|
| 246 | + /** |
|
| 247 | + * Check whether the structure has an element at the given index, optionally |
|
| 248 | + * satisfying given tag expectation. |
|
| 249 | + * |
|
| 250 | + * @param int $idx Index 0..n |
|
| 251 | + * @param int|null $expectedTag Optional type tag expectation |
|
| 252 | + * @return bool |
|
| 253 | + */ |
|
| 254 | + public function has(int $idx, $expectedTag = null): bool |
|
| 255 | + { |
|
| 256 | + if (!isset($this->_elements[$idx])) { |
|
| 257 | + return false; |
|
| 258 | + } |
|
| 259 | + if (isset($expectedTag)) { |
|
| 260 | + if (!$this->_elements[$idx]->isType($expectedTag)) { |
|
| 261 | + return false; |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + return true; |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - /** |
|
| 268 | - * Get the element at the given index, optionally checking that the element |
|
| 269 | - * has a given tag. |
|
| 270 | - * |
|
| 271 | - * <strong>NOTE!</strong> Expectation checking is deprecated and should be |
|
| 272 | - * done with <code>UnspecifiedType</code>. |
|
| 273 | - * |
|
| 274 | - * @param int $idx Index 0..n |
|
| 275 | - * @param int|null $expectedTag Optional type tag expectation |
|
| 276 | - * @throws \OutOfBoundsException If element doesn't exists |
|
| 277 | - * @throws \UnexpectedValueException If expectation fails |
|
| 278 | - * @return UnspecifiedType |
|
| 279 | - */ |
|
| 280 | - public function at(int $idx, $expectedTag = null): UnspecifiedType |
|
| 281 | - { |
|
| 282 | - if (!isset($this->_elements[$idx])) { |
|
| 283 | - throw new \OutOfBoundsException( |
|
| 284 | - "Structure doesn't have an element at index $idx."); |
|
| 285 | - } |
|
| 286 | - $element = $this->_elements[$idx]; |
|
| 287 | - if (isset($expectedTag)) { |
|
| 288 | - $element->expectType($expectedTag); |
|
| 289 | - } |
|
| 290 | - return new UnspecifiedType($element); |
|
| 291 | - } |
|
| 267 | + /** |
|
| 268 | + * Get the element at the given index, optionally checking that the element |
|
| 269 | + * has a given tag. |
|
| 270 | + * |
|
| 271 | + * <strong>NOTE!</strong> Expectation checking is deprecated and should be |
|
| 272 | + * done with <code>UnspecifiedType</code>. |
|
| 273 | + * |
|
| 274 | + * @param int $idx Index 0..n |
|
| 275 | + * @param int|null $expectedTag Optional type tag expectation |
|
| 276 | + * @throws \OutOfBoundsException If element doesn't exists |
|
| 277 | + * @throws \UnexpectedValueException If expectation fails |
|
| 278 | + * @return UnspecifiedType |
|
| 279 | + */ |
|
| 280 | + public function at(int $idx, $expectedTag = null): UnspecifiedType |
|
| 281 | + { |
|
| 282 | + if (!isset($this->_elements[$idx])) { |
|
| 283 | + throw new \OutOfBoundsException( |
|
| 284 | + "Structure doesn't have an element at index $idx."); |
|
| 285 | + } |
|
| 286 | + $element = $this->_elements[$idx]; |
|
| 287 | + if (isset($expectedTag)) { |
|
| 288 | + $element->expectType($expectedTag); |
|
| 289 | + } |
|
| 290 | + return new UnspecifiedType($element); |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - /** |
|
| 294 | - * Check whether the structure contains a context specific element with a |
|
| 295 | - * given tag. |
|
| 296 | - * |
|
| 297 | - * @param int $tag Tag number |
|
| 298 | - * @return bool |
|
| 299 | - */ |
|
| 300 | - public function hasTagged(int $tag): bool |
|
| 301 | - { |
|
| 302 | - // lazily build lookup map |
|
| 303 | - if (!isset($this->_taggedMap)) { |
|
| 304 | - $this->_taggedMap = []; |
|
| 305 | - foreach ($this->_elements as $element) { |
|
| 306 | - if ($element->isTagged()) { |
|
| 307 | - $this->_taggedMap[$element->tag()] = $element; |
|
| 308 | - } |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - return isset($this->_taggedMap[$tag]); |
|
| 312 | - } |
|
| 293 | + /** |
|
| 294 | + * Check whether the structure contains a context specific element with a |
|
| 295 | + * given tag. |
|
| 296 | + * |
|
| 297 | + * @param int $tag Tag number |
|
| 298 | + * @return bool |
|
| 299 | + */ |
|
| 300 | + public function hasTagged(int $tag): bool |
|
| 301 | + { |
|
| 302 | + // lazily build lookup map |
|
| 303 | + if (!isset($this->_taggedMap)) { |
|
| 304 | + $this->_taggedMap = []; |
|
| 305 | + foreach ($this->_elements as $element) { |
|
| 306 | + if ($element->isTagged()) { |
|
| 307 | + $this->_taggedMap[$element->tag()] = $element; |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + return isset($this->_taggedMap[$tag]); |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - /** |
|
| 315 | - * Get a context specific element tagged with a given tag. |
|
| 316 | - * |
|
| 317 | - * @param int $tag |
|
| 318 | - * @throws \LogicException If tag doesn't exists |
|
| 319 | - * @return TaggedType |
|
| 320 | - */ |
|
| 321 | - public function getTagged(int $tag): TaggedType |
|
| 322 | - { |
|
| 323 | - if (!$this->hasTagged($tag)) { |
|
| 324 | - throw new \LogicException("No tagged element for tag $tag."); |
|
| 325 | - } |
|
| 326 | - return $this->_taggedMap[$tag]; |
|
| 327 | - } |
|
| 314 | + /** |
|
| 315 | + * Get a context specific element tagged with a given tag. |
|
| 316 | + * |
|
| 317 | + * @param int $tag |
|
| 318 | + * @throws \LogicException If tag doesn't exists |
|
| 319 | + * @return TaggedType |
|
| 320 | + */ |
|
| 321 | + public function getTagged(int $tag): TaggedType |
|
| 322 | + { |
|
| 323 | + if (!$this->hasTagged($tag)) { |
|
| 324 | + throw new \LogicException("No tagged element for tag $tag."); |
|
| 325 | + } |
|
| 326 | + return $this->_taggedMap[$tag]; |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - /** |
|
| 330 | - * |
|
| 331 | - * @see \Countable::count() |
|
| 332 | - * @return int |
|
| 333 | - */ |
|
| 334 | - public function count(): int |
|
| 335 | - { |
|
| 336 | - return count($this->_elements); |
|
| 337 | - } |
|
| 329 | + /** |
|
| 330 | + * |
|
| 331 | + * @see \Countable::count() |
|
| 332 | + * @return int |
|
| 333 | + */ |
|
| 334 | + public function count(): int |
|
| 335 | + { |
|
| 336 | + return count($this->_elements); |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - /** |
|
| 340 | - * Get an iterator for the UnspecifiedElement objects. |
|
| 341 | - * |
|
| 342 | - * @see \IteratorAggregate::getIterator() |
|
| 343 | - * @return \ArrayIterator |
|
| 344 | - */ |
|
| 345 | - public function getIterator(): \ArrayIterator |
|
| 346 | - { |
|
| 347 | - return new \ArrayIterator($this->elements()); |
|
| 348 | - } |
|
| 339 | + /** |
|
| 340 | + * Get an iterator for the UnspecifiedElement objects. |
|
| 341 | + * |
|
| 342 | + * @see \IteratorAggregate::getIterator() |
|
| 343 | + * @return \ArrayIterator |
|
| 344 | + */ |
|
| 345 | + public function getIterator(): \ArrayIterator |
|
| 346 | + { |
|
| 347 | + return new \ArrayIterator($this->elements()); |
|
| 348 | + } |
|
| 349 | 349 | } |