@@ -12,24 +12,24 @@ |
||
| 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 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - protected function _validateString(string $string): bool |
|
| 32 | - { |
|
| 33 | - return 0 == preg_match('/[^0-9 ]/', $string); |
|
| 34 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + protected function _validateString(string $string): bool |
|
| 32 | + { |
|
| 33 | + return 0 == preg_match('/[^0-9 ]/', $string); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -12,24 +12,24 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class IA5String 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_IA5_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_IA5_STRING; |
|
| 25 | + parent::__construct($string); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - protected function _validateString(string $string): bool |
|
| 32 | - { |
|
| 33 | - return 0 == preg_match('/[^\x01-\x7f]/', $string); |
|
| 34 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + protected function _validateString(string $string): bool |
|
| 32 | + { |
|
| 33 | + return 0 == preg_match('/[^\x01-\x7f]/', $string); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -12,25 +12,25 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class PrintableString 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_PRINTABLE_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_PRINTABLE_STRING; |
|
| 25 | + parent::__construct($string); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - protected function _validateString(string $string): bool |
|
| 32 | - { |
|
| 33 | - $chars = preg_quote(" '()+,-./:=?]", '/'); |
|
| 34 | - return 0 == preg_match('/[^A-Za-z0-9' . $chars . ']/', $string); |
|
| 35 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + protected function _validateString(string $string): bool |
|
| 32 | + { |
|
| 33 | + $chars = preg_quote(" '()+,-./:=?]", '/'); |
|
| 34 | + return 0 == preg_match('/[^A-Za-z0-9' . $chars . ']/', $string); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -12,24 +12,24 @@ |
||
| 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 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - protected function _validateString(string $string): bool |
|
| 32 | - { |
|
| 33 | - return 0 == preg_match('/[^\x20-\x7e]/', $string); |
|
| 34 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + protected function _validateString(string $string): bool |
|
| 32 | + { |
|
| 33 | + return 0 == preg_match('/[^\x20-\x7e]/', $string); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -17,38 +17,38 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class EOC extends Element |
| 19 | 19 | { |
| 20 | - use UniversalClass; |
|
| 21 | - use PrimitiveType; |
|
| 20 | + use UniversalClass; |
|
| 21 | + use PrimitiveType; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Constructor. |
|
| 25 | - */ |
|
| 26 | - public function __construct() |
|
| 27 | - { |
|
| 28 | - $this->_typeTag = self::TYPE_EOC; |
|
| 29 | - } |
|
| 23 | + /** |
|
| 24 | + * Constructor. |
|
| 25 | + */ |
|
| 26 | + public function __construct() |
|
| 27 | + { |
|
| 28 | + $this->_typeTag = self::TYPE_EOC; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * {@inheritdoc} |
|
| 33 | - */ |
|
| 34 | - protected function _encodedContentDER(): string |
|
| 35 | - { |
|
| 36 | - return ''; |
|
| 37 | - } |
|
| 31 | + /** |
|
| 32 | + * {@inheritdoc} |
|
| 33 | + */ |
|
| 34 | + protected function _encodedContentDER(): string |
|
| 35 | + { |
|
| 36 | + return ''; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * {@inheritdoc} |
|
| 41 | - */ |
|
| 42 | - protected static function _decodeFromDER(Identifier $identifier, |
|
| 43 | - string $data, int &$offset): ElementBase |
|
| 44 | - { |
|
| 45 | - $idx = $offset; |
|
| 46 | - if (!$identifier->isPrimitive()) { |
|
| 47 | - throw new DecodeException('EOC value must be primitive.'); |
|
| 48 | - } |
|
| 49 | - // EOC type has always zero length |
|
| 50 | - Length::expectFromDER($data, $idx, 0); |
|
| 51 | - $offset = $idx; |
|
| 52 | - return new self(); |
|
| 53 | - } |
|
| 39 | + /** |
|
| 40 | + * {@inheritdoc} |
|
| 41 | + */ |
|
| 42 | + protected static function _decodeFromDER(Identifier $identifier, |
|
| 43 | + string $data, int &$offset): ElementBase |
|
| 44 | + { |
|
| 45 | + $idx = $offset; |
|
| 46 | + if (!$identifier->isPrimitive()) { |
|
| 47 | + throw new DecodeException('EOC value must be primitive.'); |
|
| 48 | + } |
|
| 49 | + // EOC type has always zero length |
|
| 50 | + Length::expectFromDER($data, $idx, 0); |
|
| 51 | + $offset = $idx; |
|
| 52 | + return new self(); |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -12,25 +12,25 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class VideotexString 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_VIDEOTEX_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_VIDEOTEX_STRING; |
|
| 25 | + parent::__construct($string); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - protected function _validateString(string $string): bool |
|
| 32 | - { |
|
| 33 | - // allow everything |
|
| 34 | - return true; |
|
| 35 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + protected function _validateString(string $string): bool |
|
| 32 | + { |
|
| 33 | + // allow everything |
|
| 34 | + return true; |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -15,28 +15,28 @@ |
||
| 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 | - * {@inheritdoc} |
|
| 33 | - */ |
|
| 34 | - protected function _validateString(string $string): bool |
|
| 35 | - { |
|
| 36 | - // UCS-2 has fixed with of 2 octets (16 bits) |
|
| 37 | - if (0 !== strlen($string) % 2) { |
|
| 38 | - return false; |
|
| 39 | - } |
|
| 40 | - return true; |
|
| 41 | - } |
|
| 31 | + /** |
|
| 32 | + * {@inheritdoc} |
|
| 33 | + */ |
|
| 34 | + protected function _validateString(string $string): bool |
|
| 35 | + { |
|
| 36 | + // UCS-2 has fixed with of 2 octets (16 bits) |
|
| 37 | + if (0 !== strlen($string) % 2) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | + return true; |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -13,36 +13,36 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class RelativeOID extends ObjectIdentifier |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Constructor. |
|
| 18 | - * |
|
| 19 | - * @param string $oid OID in dotted format |
|
| 20 | - */ |
|
| 21 | - public function __construct(string $oid) |
|
| 22 | - { |
|
| 23 | - $this->_oid = $oid; |
|
| 24 | - $this->_subids = self::_explodeDottedOID($oid); |
|
| 25 | - $this->_typeTag = self::TYPE_RELATIVE_OID; |
|
| 26 | - } |
|
| 16 | + /** |
|
| 17 | + * Constructor. |
|
| 18 | + * |
|
| 19 | + * @param string $oid OID in dotted format |
|
| 20 | + */ |
|
| 21 | + public function __construct(string $oid) |
|
| 22 | + { |
|
| 23 | + $this->_oid = $oid; |
|
| 24 | + $this->_subids = self::_explodeDottedOID($oid); |
|
| 25 | + $this->_typeTag = self::TYPE_RELATIVE_OID; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - protected function _encodedContentDER(): string |
|
| 32 | - { |
|
| 33 | - return self::_encodeSubIDs(...$this->_subids); |
|
| 34 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + protected function _encodedContentDER(): string |
|
| 32 | + { |
|
| 33 | + return self::_encodeSubIDs(...$this->_subids); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * {@inheritdoc} |
|
| 38 | - */ |
|
| 39 | - protected static function _decodeFromDER(Identifier $identifier, |
|
| 40 | - string $data, int &$offset): ElementBase |
|
| 41 | - { |
|
| 42 | - $idx = $offset; |
|
| 43 | - $len = Length::expectFromDER($data, $idx)->intLength(); |
|
| 44 | - $subids = self::_decodeSubIDs(substr($data, $idx, $len)); |
|
| 45 | - $offset = $idx + $len; |
|
| 46 | - return new self(self::_implodeSubIDs(...$subids)); |
|
| 47 | - } |
|
| 36 | + /** |
|
| 37 | + * {@inheritdoc} |
|
| 38 | + */ |
|
| 39 | + protected static function _decodeFromDER(Identifier $identifier, |
|
| 40 | + string $data, int &$offset): ElementBase |
|
| 41 | + { |
|
| 42 | + $idx = $offset; |
|
| 43 | + $len = Length::expectFromDER($data, $idx)->intLength(); |
|
| 44 | + $subids = self::_decodeSubIDs(substr($data, $idx, $len)); |
|
| 45 | + $offset = $idx + $len; |
|
| 46 | + return new self(self::_implodeSubIDs(...$subids)); |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -12,25 +12,25 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class GraphicString 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_GRAPHIC_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_GRAPHIC_STRING; |
|
| 25 | + parent::__construct($string); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - protected function _validateString(string $string): bool |
|
| 32 | - { |
|
| 33 | - // allow everything |
|
| 34 | - return true; |
|
| 35 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + protected function _validateString(string $string): bool |
|
| 32 | + { |
|
| 33 | + // allow everything |
|
| 34 | + return true; |
|
| 35 | + } |
|
| 36 | 36 | } |