Completed
Push — master ( fb1380...d10e8c )
by Joni
04:00
created
lib/X501/ASN1/AttributeValue/PseudonymValue.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@
 block discarded – undo
15 15
  */
16 16
 class PseudonymValue extends DirectoryString
17 17
 {
18
-    /**
19
-     * Constructor.
20
-     *
21
-     * @param string $value String value
22
-     * @param int $string_tag Syntax choice
23
-     */
24
-    public function __construct(string $value,
25
-        int $string_tag = DirectoryString::UTF8)
26
-    {
27
-        $this->_oid = AttributeType::OID_PSEUDONYM;
28
-        parent::__construct($value, $string_tag);
29
-    }
18
+	/**
19
+	 * Constructor.
20
+	 *
21
+	 * @param string $value String value
22
+	 * @param int $string_tag Syntax choice
23
+	 */
24
+	public function __construct(string $value,
25
+		int $string_tag = DirectoryString::UTF8)
26
+	{
27
+		$this->_oid = AttributeType::OID_PSEUDONYM;
28
+		parent::__construct($value, $string_tag);
29
+	}
30 30
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/AttributeValue.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -17,154 +17,154 @@
 block discarded – undo
17 17
  */
18 18
 abstract class AttributeValue
19 19
 {
20
-    /**
21
-     * Mapping from attribute type OID to attribute value class name.
22
-     *
23
-     * @internal
24
-     *
25
-     * @var array
26
-     */
27
-    const MAP_OID_TO_CLASS = array(
28
-        /* @formatter:off */
29
-        AttributeType::OID_COMMON_NAME => CommonNameValue::class,
30
-        AttributeType::OID_SURNAME => SurnameValue::class,
31
-        AttributeType::OID_SERIAL_NUMBER => SerialNumberValue::class,
32
-        AttributeType::OID_COUNTRY_NAME => CountryNameValue::class,
33
-        AttributeType::OID_LOCALITY_NAME => LocalityNameValue::class,
34
-        AttributeType::OID_STATE_OR_PROVINCE_NAME => StateOrProvinceNameValue::class,
35
-        AttributeType::OID_ORGANIZATION_NAME => OrganizationNameValue::class,
36
-        AttributeType::OID_ORGANIZATIONAL_UNIT_NAME => OrganizationalUnitNameValue::class,
37
-        AttributeType::OID_TITLE => TitleValue::class,
38
-        AttributeType::OID_DESCRIPTION => DescriptionValue::class,
39
-        AttributeType::OID_NAME => NameValue::class,
40
-        AttributeType::OID_GIVEN_NAME => GivenNameValue::class,
41
-        AttributeType::OID_PSEUDONYM => PseudonymValue::class
42
-        /* @formatter:on */
43
-    );
20
+	/**
21
+	 * Mapping from attribute type OID to attribute value class name.
22
+	 *
23
+	 * @internal
24
+	 *
25
+	 * @var array
26
+	 */
27
+	const MAP_OID_TO_CLASS = array(
28
+		/* @formatter:off */
29
+		AttributeType::OID_COMMON_NAME => CommonNameValue::class,
30
+		AttributeType::OID_SURNAME => SurnameValue::class,
31
+		AttributeType::OID_SERIAL_NUMBER => SerialNumberValue::class,
32
+		AttributeType::OID_COUNTRY_NAME => CountryNameValue::class,
33
+		AttributeType::OID_LOCALITY_NAME => LocalityNameValue::class,
34
+		AttributeType::OID_STATE_OR_PROVINCE_NAME => StateOrProvinceNameValue::class,
35
+		AttributeType::OID_ORGANIZATION_NAME => OrganizationNameValue::class,
36
+		AttributeType::OID_ORGANIZATIONAL_UNIT_NAME => OrganizationalUnitNameValue::class,
37
+		AttributeType::OID_TITLE => TitleValue::class,
38
+		AttributeType::OID_DESCRIPTION => DescriptionValue::class,
39
+		AttributeType::OID_NAME => NameValue::class,
40
+		AttributeType::OID_GIVEN_NAME => GivenNameValue::class,
41
+		AttributeType::OID_PSEUDONYM => PseudonymValue::class
42
+		/* @formatter:on */
43
+	);
44 44
     
45
-    /**
46
-     * OID of the attribute type.
47
-     *
48
-     * @var string $_oid
49
-     */
50
-    protected $_oid;
45
+	/**
46
+	 * OID of the attribute type.
47
+	 *
48
+	 * @var string $_oid
49
+	 */
50
+	protected $_oid;
51 51
     
52
-    /**
53
-     * Generate ASN.1 element.
54
-     *
55
-     * @return \ASN1\Element
56
-     */
57
-    abstract public function toASN1();
52
+	/**
53
+	 * Generate ASN.1 element.
54
+	 *
55
+	 * @return \ASN1\Element
56
+	 */
57
+	abstract public function toASN1();
58 58
     
59
-    /**
60
-     * Get attribute value as a string
61
-     *
62
-     * @return string
63
-     */
64
-    abstract public function stringValue(): string;
59
+	/**
60
+	 * Get attribute value as a string
61
+	 *
62
+	 * @return string
63
+	 */
64
+	abstract public function stringValue(): string;
65 65
     
66
-    /**
67
-     * Get matching rule for equality comparison.
68
-     *
69
-     * @return \X501\MatchingRule\MatchingRule
70
-     */
71
-    abstract public function equalityMatchingRule();
66
+	/**
67
+	 * Get matching rule for equality comparison.
68
+	 *
69
+	 * @return \X501\MatchingRule\MatchingRule
70
+	 */
71
+	abstract public function equalityMatchingRule();
72 72
     
73
-    /**
74
-     * Get attribute value as a string conforming to RFC 2253.
75
-     *
76
-     * @link https://tools.ietf.org/html/rfc2253#section-2.4
77
-     * @return string
78
-     */
79
-    abstract public function rfc2253String(): string;
73
+	/**
74
+	 * Get attribute value as a string conforming to RFC 2253.
75
+	 *
76
+	 * @link https://tools.ietf.org/html/rfc2253#section-2.4
77
+	 * @return string
78
+	 */
79
+	abstract public function rfc2253String(): string;
80 80
     
81
-    /**
82
-     * Get attribute value as an UTF-8 string conforming to RFC 4518.
83
-     *
84
-     * @link https://tools.ietf.org/html/rfc4518#section-2.1
85
-     * @return string
86
-     */
87
-    abstract protected function _transcodedString(): string;
81
+	/**
82
+	 * Get attribute value as an UTF-8 string conforming to RFC 4518.
83
+	 *
84
+	 * @link https://tools.ietf.org/html/rfc4518#section-2.1
85
+	 * @return string
86
+	 */
87
+	abstract protected function _transcodedString(): string;
88 88
     
89
-    /**
90
-     * Initialize from ASN.1.
91
-     *
92
-     * @param UnspecifiedType $el
93
-     * @return self
94
-     */
95
-    public static function fromASN1(UnspecifiedType $el)
96
-    {
97
-        throw new \BadMethodCallException(
98
-            "ASN.1 parsing must be implemented in a concrete class.");
99
-    }
89
+	/**
90
+	 * Initialize from ASN.1.
91
+	 *
92
+	 * @param UnspecifiedType $el
93
+	 * @return self
94
+	 */
95
+	public static function fromASN1(UnspecifiedType $el)
96
+	{
97
+		throw new \BadMethodCallException(
98
+			"ASN.1 parsing must be implemented in a concrete class.");
99
+	}
100 100
     
101
-    /**
102
-     * Initialize from ASN.1 with given OID hint.
103
-     *
104
-     * @param string $oid Attribute's OID
105
-     * @param UnspecifiedType $el
106
-     * @return self
107
-     */
108
-    public static function fromASN1ByOID(string $oid, UnspecifiedType $el): self
109
-    {
110
-        if (!array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
111
-            return new UnknownAttributeValue($oid, $el->asElement());
112
-        }
113
-        $cls = self::MAP_OID_TO_CLASS[$oid];
114
-        return $cls::fromASN1($el);
115
-    }
101
+	/**
102
+	 * Initialize from ASN.1 with given OID hint.
103
+	 *
104
+	 * @param string $oid Attribute's OID
105
+	 * @param UnspecifiedType $el
106
+	 * @return self
107
+	 */
108
+	public static function fromASN1ByOID(string $oid, UnspecifiedType $el): self
109
+	{
110
+		if (!array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
111
+			return new UnknownAttributeValue($oid, $el->asElement());
112
+		}
113
+		$cls = self::MAP_OID_TO_CLASS[$oid];
114
+		return $cls::fromASN1($el);
115
+	}
116 116
     
117
-    /**
118
-     * Initialize from another AttributeValue.
119
-     *
120
-     * This method is generally used to cast UnknownAttributeValue to
121
-     * specific object when class is declared outside this package.
122
-     *
123
-     * @param self $obj Instance of AttributeValue
124
-     * @return self
125
-     */
126
-    public static function fromSelf(self $obj): self
127
-    {
128
-        return static::fromASN1($obj->toASN1()->asUnspecified());
129
-    }
117
+	/**
118
+	 * Initialize from another AttributeValue.
119
+	 *
120
+	 * This method is generally used to cast UnknownAttributeValue to
121
+	 * specific object when class is declared outside this package.
122
+	 *
123
+	 * @param self $obj Instance of AttributeValue
124
+	 * @return self
125
+	 */
126
+	public static function fromSelf(self $obj): self
127
+	{
128
+		return static::fromASN1($obj->toASN1()->asUnspecified());
129
+	}
130 130
     
131
-    /**
132
-     * Get attribute type's OID.
133
-     *
134
-     * @return string
135
-     */
136
-    public function oid(): string
137
-    {
138
-        return $this->_oid;
139
-    }
131
+	/**
132
+	 * Get attribute type's OID.
133
+	 *
134
+	 * @return string
135
+	 */
136
+	public function oid(): string
137
+	{
138
+		return $this->_oid;
139
+	}
140 140
     
141
-    /**
142
-     * Get Attribute object with this as a single value.
143
-     *
144
-     * @return Attribute
145
-     */
146
-    public function toAttribute(): Attribute
147
-    {
148
-        return Attribute::fromAttributeValues($this);
149
-    }
141
+	/**
142
+	 * Get Attribute object with this as a single value.
143
+	 *
144
+	 * @return Attribute
145
+	 */
146
+	public function toAttribute(): Attribute
147
+	{
148
+		return Attribute::fromAttributeValues($this);
149
+	}
150 150
     
151
-    /**
152
-     * Get AttributeTypeAndValue object with this as a value.
153
-     *
154
-     * @return AttributeTypeAndValue
155
-     */
156
-    public function toAttributeTypeAndValue(): AttributeTypeAndValue
157
-    {
158
-        return AttributeTypeAndValue::fromAttributeValue($this);
159
-    }
151
+	/**
152
+	 * Get AttributeTypeAndValue object with this as a value.
153
+	 *
154
+	 * @return AttributeTypeAndValue
155
+	 */
156
+	public function toAttributeTypeAndValue(): AttributeTypeAndValue
157
+	{
158
+		return AttributeTypeAndValue::fromAttributeValue($this);
159
+	}
160 160
     
161
-    /**
162
-     * Get attribute value as an UTF-8 encoded string.
163
-     *
164
-     * @return string
165
-     */
166
-    public function __toString()
167
-    {
168
-        return $this->_transcodedString();
169
-    }
161
+	/**
162
+	 * Get attribute value as an UTF-8 encoded string.
163
+	 *
164
+	 * @return string
165
+	 */
166
+	public function __toString()
167
+	{
168
+		return $this->_transcodedString();
169
+	}
170 170
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/CountryNameValue.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@
 block discarded – undo
15 15
  */
16 16
 class CountryNameValue extends PrintableStringValue
17 17
 {
18
-    /**
19
-     * Constructor.
20
-     *
21
-     * @param string $value String value
22
-     */
23
-    public function __construct(string $value)
24
-    {
25
-        $this->_oid = AttributeType::OID_COUNTRY_NAME;
26
-        parent::__construct($value);
27
-    }
18
+	/**
19
+	 * Constructor.
20
+	 *
21
+	 * @param string $value String value
22
+	 */
23
+	public function __construct(string $value)
24
+	{
25
+		$this->_oid = AttributeType::OID_COUNTRY_NAME;
26
+		parent::__construct($value);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/CommonNameValue.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@
 block discarded – undo
15 15
  */
16 16
 class CommonNameValue extends DirectoryString
17 17
 {
18
-    /**
19
-     * Constructor.
20
-     *
21
-     * @param string $value String value
22
-     * @param int $string_tag Syntax choice
23
-     */
24
-    public function __construct(string $value,
25
-        int $string_tag = DirectoryString::UTF8)
26
-    {
27
-        $this->_oid = AttributeType::OID_COMMON_NAME;
28
-        parent::__construct($value, $string_tag);
29
-    }
18
+	/**
19
+	 * Constructor.
20
+	 *
21
+	 * @param string $value String value
22
+	 * @param int $string_tag Syntax choice
23
+	 */
24
+	public function __construct(string $value,
25
+		int $string_tag = DirectoryString::UTF8)
26
+	{
27
+		$this->_oid = AttributeType::OID_COMMON_NAME;
28
+		parent::__construct($value, $string_tag);
29
+	}
30 30
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/UnknownAttributeValue.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -12,73 +12,73 @@
 block discarded – undo
12 12
  */
13 13
 class UnknownAttributeValue extends AttributeValue
14 14
 {
15
-    /**
16
-     * ASN.1 element.
17
-     *
18
-     * @var Element $_element
19
-     */
20
-    protected $_element;
15
+	/**
16
+	 * ASN.1 element.
17
+	 *
18
+	 * @var Element $_element
19
+	 */
20
+	protected $_element;
21 21
     
22
-    /**
23
-     * Constructor.
24
-     *
25
-     * @param string $oid
26
-     * @param Element $el
27
-     */
28
-    public function __construct(string $oid, Element $el)
29
-    {
30
-        $this->_oid = $oid;
31
-        $this->_element = $el;
32
-    }
22
+	/**
23
+	 * Constructor.
24
+	 *
25
+	 * @param string $oid
26
+	 * @param Element $el
27
+	 */
28
+	public function __construct(string $oid, Element $el)
29
+	{
30
+		$this->_oid = $oid;
31
+		$this->_element = $el;
32
+	}
33 33
     
34
-    /**
35
-     *
36
-     * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
37
-     * @return Element
38
-     */
39
-    public function toASN1(): Element
40
-    {
41
-        return $this->_element;
42
-    }
34
+	/**
35
+	 *
36
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::toASN1()
37
+	 * @return Element
38
+	 */
39
+	public function toASN1(): Element
40
+	{
41
+		return $this->_element;
42
+	}
43 43
     
44
-    /**
45
-     *
46
-     * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
47
-     * @return string
48
-     */
49
-    public function stringValue(): string
50
-    {
51
-        // return DER encoding as a hexstring
52
-        return "#" . bin2hex($this->_element->toDER());
53
-    }
44
+	/**
45
+	 *
46
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::stringValue()
47
+	 * @return string
48
+	 */
49
+	public function stringValue(): string
50
+	{
51
+		// return DER encoding as a hexstring
52
+		return "#" . bin2hex($this->_element->toDER());
53
+	}
54 54
     
55
-    /**
56
-     *
57
-     * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
58
-     * @return BinaryMatch
59
-     */
60
-    public function equalityMatchingRule()
61
-    {
62
-        return new BinaryMatch();
63
-    }
55
+	/**
56
+	 *
57
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::equalityMatchingRule()
58
+	 * @return BinaryMatch
59
+	 */
60
+	public function equalityMatchingRule()
61
+	{
62
+		return new BinaryMatch();
63
+	}
64 64
     
65
-    /**
66
-     *
67
-     * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
68
-     * @return string
69
-     */
70
-    public function rfc2253String(): string
71
-    {
72
-        return $this->stringValue();
73
-    }
65
+	/**
66
+	 *
67
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::rfc2253String()
68
+	 * @return string
69
+	 */
70
+	public function rfc2253String(): string
71
+	{
72
+		return $this->stringValue();
73
+	}
74 74
     
75
-    /**
76
-     *
77
-     * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
78
-     * @return string
79
-     */
80
-    protected function _transcodedString(): string
81
-    {
82
-        return $this->stringValue();
83
-    }
75
+	/**
76
+	 *
77
+	 * @see \X501\ASN1\AttributeValue\AttributeValue::_transcodedString()
78
+	 * @return string
79
+	 */
80
+	protected function _transcodedString(): string
81
+	{
82
+		return $this->stringValue();
83
+	}
84 84
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/TitleValue.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@
 block discarded – undo
15 15
  */
16 16
 class TitleValue extends DirectoryString
17 17
 {
18
-    /**
19
-     * Constructor.
20
-     *
21
-     * @param string $value String value
22
-     * @param int $string_tag Syntax choice
23
-     */
24
-    public function __construct(string $value,
25
-        int $string_tag = DirectoryString::UTF8)
26
-    {
27
-        $this->_oid = AttributeType::OID_TITLE;
28
-        parent::__construct($value, $string_tag);
29
-    }
18
+	/**
19
+	 * Constructor.
20
+	 *
21
+	 * @param string $value String value
22
+	 * @param int $string_tag Syntax choice
23
+	 */
24
+	public function __construct(string $value,
25
+		int $string_tag = DirectoryString::UTF8)
26
+	{
27
+		$this->_oid = AttributeType::OID_TITLE;
28
+		parent::__construct($value, $string_tag);
29
+	}
30 30
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/Attribute.php 2 patches
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -18,157 +18,157 @@
 block discarded – undo
18 18
  */
19 19
 class Attribute implements \Countable, \IteratorAggregate
20 20
 {
21
-    use TypedAttribute;
21
+	use TypedAttribute;
22 22
     
23
-    /**
24
-     * Attribute values.
25
-     *
26
-     * @var AttributeValue[]
27
-     */
28
-    protected $_values;
23
+	/**
24
+	 * Attribute values.
25
+	 *
26
+	 * @var AttributeValue[]
27
+	 */
28
+	protected $_values;
29 29
     
30
-    /**
31
-     * Constructor.
32
-     *
33
-     * @param AttributeType $type Attribute type
34
-     * @param AttributeValue ...$values Attribute values
35
-     */
36
-    public function __construct(AttributeType $type, AttributeValue ...$values)
37
-    {
38
-        // check that attribute values have correct oid
39
-        array_walk($values,
40
-            function (AttributeValue $value) use ($type) {
41
-                if ($value->oid() != $type->oid()) {
42
-                    throw new \LogicException("Attribute OID mismatch.");
43
-                }
44
-            });
45
-        $this->_type = $type;
46
-        $this->_values = $values;
47
-    }
30
+	/**
31
+	 * Constructor.
32
+	 *
33
+	 * @param AttributeType $type Attribute type
34
+	 * @param AttributeValue ...$values Attribute values
35
+	 */
36
+	public function __construct(AttributeType $type, AttributeValue ...$values)
37
+	{
38
+		// check that attribute values have correct oid
39
+		array_walk($values,
40
+			function (AttributeValue $value) use ($type) {
41
+				if ($value->oid() != $type->oid()) {
42
+					throw new \LogicException("Attribute OID mismatch.");
43
+				}
44
+			});
45
+		$this->_type = $type;
46
+		$this->_values = $values;
47
+	}
48 48
     
49
-    /**
50
-     * Initialize from ASN.1.
51
-     *
52
-     * @param Sequence $seq
53
-     * @return self
54
-     */
55
-    public static function fromASN1(Sequence $seq): self
56
-    {
57
-        $type = AttributeType::fromASN1($seq->at(0)->asObjectIdentifier());
58
-        $values = array_map(
59
-            function (UnspecifiedType $el) use ($type) {
60
-                return AttributeValue::fromASN1ByOID($type->oid(), $el);
61
-            }, $seq->at(1)
62
-                ->asSet()
63
-                ->elements());
64
-        return new self($type, ...$values);
65
-    }
49
+	/**
50
+	 * Initialize from ASN.1.
51
+	 *
52
+	 * @param Sequence $seq
53
+	 * @return self
54
+	 */
55
+	public static function fromASN1(Sequence $seq): self
56
+	{
57
+		$type = AttributeType::fromASN1($seq->at(0)->asObjectIdentifier());
58
+		$values = array_map(
59
+			function (UnspecifiedType $el) use ($type) {
60
+				return AttributeValue::fromASN1ByOID($type->oid(), $el);
61
+			}, $seq->at(1)
62
+				->asSet()
63
+				->elements());
64
+		return new self($type, ...$values);
65
+	}
66 66
     
67
-    /**
68
-     * Convenience method to initialize from attribute values.
69
-     *
70
-     * @param AttributeValue ...$values One or more values
71
-     * @throws \LogicException
72
-     * @return self
73
-     */
74
-    public static function fromAttributeValues(AttributeValue ...$values): self
75
-    {
76
-        // we need at least one value to determine OID
77
-        if (!count($values)) {
78
-            throw new \LogicException("No values.");
79
-        }
80
-        $oid = reset($values)->oid();
81
-        return new self(new AttributeType($oid), ...$values);
82
-    }
67
+	/**
68
+	 * Convenience method to initialize from attribute values.
69
+	 *
70
+	 * @param AttributeValue ...$values One or more values
71
+	 * @throws \LogicException
72
+	 * @return self
73
+	 */
74
+	public static function fromAttributeValues(AttributeValue ...$values): self
75
+	{
76
+		// we need at least one value to determine OID
77
+		if (!count($values)) {
78
+			throw new \LogicException("No values.");
79
+		}
80
+		$oid = reset($values)->oid();
81
+		return new self(new AttributeType($oid), ...$values);
82
+	}
83 83
     
84
-    /**
85
-     * Get first value of the attribute.
86
-     *
87
-     * @throws \LogicException
88
-     * @return AttributeValue
89
-     */
90
-    public function first(): AttributeValue
91
-    {
92
-        if (!count($this->_values)) {
93
-            throw new \LogicException("Attribute contains no values.");
94
-        }
95
-        return $this->_values[0];
96
-    }
84
+	/**
85
+	 * Get first value of the attribute.
86
+	 *
87
+	 * @throws \LogicException
88
+	 * @return AttributeValue
89
+	 */
90
+	public function first(): AttributeValue
91
+	{
92
+		if (!count($this->_values)) {
93
+			throw new \LogicException("Attribute contains no values.");
94
+		}
95
+		return $this->_values[0];
96
+	}
97 97
     
98
-    /**
99
-     * Get all values.
100
-     *
101
-     * @return AttributeValue[]
102
-     */
103
-    public function values(): array
104
-    {
105
-        return $this->_values;
106
-    }
98
+	/**
99
+	 * Get all values.
100
+	 *
101
+	 * @return AttributeValue[]
102
+	 */
103
+	public function values(): array
104
+	{
105
+		return $this->_values;
106
+	}
107 107
     
108
-    /**
109
-     * Generate ASN.1 structure.
110
-     *
111
-     * @return Sequence
112
-     */
113
-    public function toASN1(): Sequence
114
-    {
115
-        $values = array_map(
116
-            function (AttributeValue $value) {
117
-                return $value->toASN1();
118
-            }, $this->_values);
119
-        $valueset = new Set(...$values);
120
-        return new Sequence($this->_type->toASN1(), $valueset->sortedSetOf());
121
-    }
108
+	/**
109
+	 * Generate ASN.1 structure.
110
+	 *
111
+	 * @return Sequence
112
+	 */
113
+	public function toASN1(): Sequence
114
+	{
115
+		$values = array_map(
116
+			function (AttributeValue $value) {
117
+				return $value->toASN1();
118
+			}, $this->_values);
119
+		$valueset = new Set(...$values);
120
+		return new Sequence($this->_type->toASN1(), $valueset->sortedSetOf());
121
+	}
122 122
     
123
-    /**
124
-     * Cast attribute values to another AttributeValue class.
125
-     *
126
-     * This method is generally used to cast UnknownAttributeValue values
127
-     * to specific objects when class is declared outside this package.
128
-     *
129
-     * The new class must be derived from AttributeValue and have the same OID
130
-     * as current attribute values.
131
-     *
132
-     * @param string $cls AttributeValue class name
133
-     * @throws \LogicException
134
-     * @return self
135
-     */
136
-    public function castValues(string $cls): self
137
-    {
138
-        $refl = new \ReflectionClass($cls);
139
-        if (!$refl->isSubclassOf(AttributeValue::class)) {
140
-            throw new \LogicException(
141
-                "$cls must be derived from " . AttributeValue::class . ".");
142
-        }
143
-        $oid = $this->oid();
144
-        $values = array_map(
145
-            function (AttributeValue $value) use ($cls, $oid) {
146
-                $value = $cls::fromSelf($value);
147
-                if ($value->oid() != $oid) {
148
-                    throw new \LogicException("Attribute OID mismatch.");
149
-                }
150
-                return $value;
151
-            }, $this->_values);
152
-        return self::fromAttributeValues(...$values);
153
-    }
123
+	/**
124
+	 * Cast attribute values to another AttributeValue class.
125
+	 *
126
+	 * This method is generally used to cast UnknownAttributeValue values
127
+	 * to specific objects when class is declared outside this package.
128
+	 *
129
+	 * The new class must be derived from AttributeValue and have the same OID
130
+	 * as current attribute values.
131
+	 *
132
+	 * @param string $cls AttributeValue class name
133
+	 * @throws \LogicException
134
+	 * @return self
135
+	 */
136
+	public function castValues(string $cls): self
137
+	{
138
+		$refl = new \ReflectionClass($cls);
139
+		if (!$refl->isSubclassOf(AttributeValue::class)) {
140
+			throw new \LogicException(
141
+				"$cls must be derived from " . AttributeValue::class . ".");
142
+		}
143
+		$oid = $this->oid();
144
+		$values = array_map(
145
+			function (AttributeValue $value) use ($cls, $oid) {
146
+				$value = $cls::fromSelf($value);
147
+				if ($value->oid() != $oid) {
148
+					throw new \LogicException("Attribute OID mismatch.");
149
+				}
150
+				return $value;
151
+			}, $this->_values);
152
+		return self::fromAttributeValues(...$values);
153
+	}
154 154
     
155
-    /**
156
-     *
157
-     * @see \Countable::count()
158
-     * @return int
159
-     */
160
-    public function count(): int
161
-    {
162
-        return count($this->_values);
163
-    }
155
+	/**
156
+	 *
157
+	 * @see \Countable::count()
158
+	 * @return int
159
+	 */
160
+	public function count(): int
161
+	{
162
+		return count($this->_values);
163
+	}
164 164
     
165
-    /**
166
-     *
167
-     * @see \IteratorAggregate::getIterator()
168
-     * @return \ArrayIterator
169
-     */
170
-    public function getIterator(): \ArrayIterator
171
-    {
172
-        return new \ArrayIterator($this->_values);
173
-    }
165
+	/**
166
+	 *
167
+	 * @see \IteratorAggregate::getIterator()
168
+	 * @return \ArrayIterator
169
+	 */
170
+	public function getIterator(): \ArrayIterator
171
+	{
172
+		return new \ArrayIterator($this->_values);
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     {
38 38
         // check that attribute values have correct oid
39 39
         array_walk($values,
40
-            function (AttributeValue $value) use ($type) {
40
+            function(AttributeValue $value) use ($type) {
41 41
                 if ($value->oid() != $type->oid()) {
42 42
                     throw new \LogicException("Attribute OID mismatch.");
43 43
                 }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     {
57 57
         $type = AttributeType::fromASN1($seq->at(0)->asObjectIdentifier());
58 58
         $values = array_map(
59
-            function (UnspecifiedType $el) use ($type) {
59
+            function(UnspecifiedType $el) use ($type) {
60 60
                 return AttributeValue::fromASN1ByOID($type->oid(), $el);
61 61
             }, $seq->at(1)
62 62
                 ->asSet()
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     public function toASN1(): Sequence
114 114
     {
115 115
         $values = array_map(
116
-            function (AttributeValue $value) {
116
+            function(AttributeValue $value) {
117 117
                 return $value->toASN1();
118 118
             }, $this->_values);
119 119
         $valueset = new Set(...$values);
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         }
143 143
         $oid = $this->oid();
144 144
         $values = array_map(
145
-            function (AttributeValue $value) use ($cls, $oid) {
145
+            function(AttributeValue $value) use ($cls, $oid) {
146 146
                 $value = $cls::fromSelf($value);
147 147
                 if ($value->oid() != $oid) {
148 148
                     throw new \LogicException("Attribute OID mismatch.");
Please login to merge, or discard this patch.