Passed
Push — master ( d10e8c...c6bdb0 )
by Joni
03:28
created
lib/X501/ASN1/AttributeValue/NameValue.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class NameValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_NAME;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_NAME;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/OrganizationNameValue.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class OrganizationNameValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_ORGANIZATION_NAME;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_ORGANIZATION_NAME;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/DescriptionValue.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class DescriptionValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_DESCRIPTION;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_DESCRIPTION;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/GivenNameValue.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class GivenNameValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_GIVEN_NAME;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_GIVEN_NAME;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/OrganizationalUnitNameValue.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class OrganizationalUnitNameValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_ORGANIZATIONAL_UNIT_NAME;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_ORGANIZATIONAL_UNIT_NAME;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/AttributeValue.php 1 patch
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -18,157 +18,157 @@
 block discarded – undo
18 18
  */
19 19
 abstract class AttributeValue
20 20
 {
21
-    /**
22
-     * Mapping from attribute type OID to attribute value class name.
23
-     *
24
-     * @internal
25
-     *
26
-     * @var array
27
-     */
28
-    const MAP_OID_TO_CLASS = [
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
-    ];
43
-
44
-    /**
45
-     * OID of the attribute type.
46
-     *
47
-     * @var string
48
-     */
49
-    protected $_oid;
50
-
51
-    /**
52
-     * Get attribute value as an UTF-8 encoded string.
53
-     *
54
-     * @return string
55
-     */
56
-    public function __toString()
57
-    {
58
-        return $this->_transcodedString();
59
-    }
60
-
61
-    /**
62
-     * Generate ASN.1 element.
63
-     *
64
-     * @return Element
65
-     */
66
-    abstract public function toASN1(): Element;
67
-
68
-    /**
69
-     * Get attribute value as a string.
70
-     *
71
-     * @return string
72
-     */
73
-    abstract public function stringValue(): string;
74
-
75
-    /**
76
-     * Get matching rule for equality comparison.
77
-     *
78
-     * @return MatchingRule
79
-     */
80
-    abstract public function equalityMatchingRule(): MatchingRule;
81
-
82
-    /**
83
-     * Get attribute value as a string conforming to RFC 2253.
84
-     *
85
-     * @see https://tools.ietf.org/html/rfc2253#section-2.4
86
-     *
87
-     * @return string
88
-     */
89
-    abstract public function rfc2253String(): string;
90
-
91
-    /**
92
-     * Initialize from ASN.1.
93
-     *
94
-     * @param UnspecifiedType $el
95
-     *
96
-     * @return self
97
-     */
98
-    public static function fromASN1(UnspecifiedType $el): AttributeValue
99
-    {
100
-        throw new \BadMethodCallException(
101
-            'ASN.1 parsing must be implemented in a concrete class.');
102
-    }
103
-
104
-    /**
105
-     * Initialize from ASN.1 with given OID hint.
106
-     *
107
-     * @param string          $oid Attribute's OID
108
-     * @param UnspecifiedType $el
109
-     *
110
-     * @return self
111
-     */
112
-    public static function fromASN1ByOID(string $oid, UnspecifiedType $el): self
113
-    {
114
-        if (!array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
115
-            return new UnknownAttributeValue($oid, $el->asElement());
116
-        }
117
-        $cls = self::MAP_OID_TO_CLASS[$oid];
118
-        return $cls::fromASN1($el);
119
-    }
120
-
121
-    /**
122
-     * Initialize from another AttributeValue.
123
-     *
124
-     * This method is generally used to cast UnknownAttributeValue to
125
-     * specific object when class is declared outside this package.
126
-     *
127
-     * @param self $obj Instance of AttributeValue
128
-     *
129
-     * @return self
130
-     */
131
-    public static function fromSelf(self $obj): self
132
-    {
133
-        return static::fromASN1($obj->toASN1()->asUnspecified());
134
-    }
135
-
136
-    /**
137
-     * Get attribute type's OID.
138
-     *
139
-     * @return string
140
-     */
141
-    public function oid(): string
142
-    {
143
-        return $this->_oid;
144
-    }
145
-
146
-    /**
147
-     * Get Attribute object with this as a single value.
148
-     *
149
-     * @return Attribute
150
-     */
151
-    public function toAttribute(): Attribute
152
-    {
153
-        return Attribute::fromAttributeValues($this);
154
-    }
155
-
156
-    /**
157
-     * Get AttributeTypeAndValue object with this as a value.
158
-     *
159
-     * @return AttributeTypeAndValue
160
-     */
161
-    public function toAttributeTypeAndValue(): AttributeTypeAndValue
162
-    {
163
-        return AttributeTypeAndValue::fromAttributeValue($this);
164
-    }
165
-
166
-    /**
167
-     * Get attribute value as an UTF-8 string conforming to RFC 4518.
168
-     *
169
-     * @see https://tools.ietf.org/html/rfc4518#section-2.1
170
-     *
171
-     * @return string
172
-     */
173
-    abstract protected function _transcodedString(): string;
21
+	/**
22
+	 * Mapping from attribute type OID to attribute value class name.
23
+	 *
24
+	 * @internal
25
+	 *
26
+	 * @var array
27
+	 */
28
+	const MAP_OID_TO_CLASS = [
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
+	];
43
+
44
+	/**
45
+	 * OID of the attribute type.
46
+	 *
47
+	 * @var string
48
+	 */
49
+	protected $_oid;
50
+
51
+	/**
52
+	 * Get attribute value as an UTF-8 encoded string.
53
+	 *
54
+	 * @return string
55
+	 */
56
+	public function __toString()
57
+	{
58
+		return $this->_transcodedString();
59
+	}
60
+
61
+	/**
62
+	 * Generate ASN.1 element.
63
+	 *
64
+	 * @return Element
65
+	 */
66
+	abstract public function toASN1(): Element;
67
+
68
+	/**
69
+	 * Get attribute value as a string.
70
+	 *
71
+	 * @return string
72
+	 */
73
+	abstract public function stringValue(): string;
74
+
75
+	/**
76
+	 * Get matching rule for equality comparison.
77
+	 *
78
+	 * @return MatchingRule
79
+	 */
80
+	abstract public function equalityMatchingRule(): MatchingRule;
81
+
82
+	/**
83
+	 * Get attribute value as a string conforming to RFC 2253.
84
+	 *
85
+	 * @see https://tools.ietf.org/html/rfc2253#section-2.4
86
+	 *
87
+	 * @return string
88
+	 */
89
+	abstract public function rfc2253String(): string;
90
+
91
+	/**
92
+	 * Initialize from ASN.1.
93
+	 *
94
+	 * @param UnspecifiedType $el
95
+	 *
96
+	 * @return self
97
+	 */
98
+	public static function fromASN1(UnspecifiedType $el): AttributeValue
99
+	{
100
+		throw new \BadMethodCallException(
101
+			'ASN.1 parsing must be implemented in a concrete class.');
102
+	}
103
+
104
+	/**
105
+	 * Initialize from ASN.1 with given OID hint.
106
+	 *
107
+	 * @param string          $oid Attribute's OID
108
+	 * @param UnspecifiedType $el
109
+	 *
110
+	 * @return self
111
+	 */
112
+	public static function fromASN1ByOID(string $oid, UnspecifiedType $el): self
113
+	{
114
+		if (!array_key_exists($oid, self::MAP_OID_TO_CLASS)) {
115
+			return new UnknownAttributeValue($oid, $el->asElement());
116
+		}
117
+		$cls = self::MAP_OID_TO_CLASS[$oid];
118
+		return $cls::fromASN1($el);
119
+	}
120
+
121
+	/**
122
+	 * Initialize from another AttributeValue.
123
+	 *
124
+	 * This method is generally used to cast UnknownAttributeValue to
125
+	 * specific object when class is declared outside this package.
126
+	 *
127
+	 * @param self $obj Instance of AttributeValue
128
+	 *
129
+	 * @return self
130
+	 */
131
+	public static function fromSelf(self $obj): self
132
+	{
133
+		return static::fromASN1($obj->toASN1()->asUnspecified());
134
+	}
135
+
136
+	/**
137
+	 * Get attribute type's OID.
138
+	 *
139
+	 * @return string
140
+	 */
141
+	public function oid(): string
142
+	{
143
+		return $this->_oid;
144
+	}
145
+
146
+	/**
147
+	 * Get Attribute object with this as a single value.
148
+	 *
149
+	 * @return Attribute
150
+	 */
151
+	public function toAttribute(): Attribute
152
+	{
153
+		return Attribute::fromAttributeValues($this);
154
+	}
155
+
156
+	/**
157
+	 * Get AttributeTypeAndValue object with this as a value.
158
+	 *
159
+	 * @return AttributeTypeAndValue
160
+	 */
161
+	public function toAttributeTypeAndValue(): AttributeTypeAndValue
162
+	{
163
+		return AttributeTypeAndValue::fromAttributeValue($this);
164
+	}
165
+
166
+	/**
167
+	 * Get attribute value as an UTF-8 string conforming to RFC 4518.
168
+	 *
169
+	 * @see https://tools.ietf.org/html/rfc4518#section-2.1
170
+	 *
171
+	 * @return string
172
+	 */
173
+	abstract protected function _transcodedString(): string;
174 174
 }
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
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class CommonNameValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_COMMON_NAME;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_COMMON_NAME;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
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
@@ -14,16 +14,16 @@
 block discarded – undo
14 14
  */
15 15
 class TitleValue extends DirectoryString
16 16
 {
17
-    /**
18
-     * Constructor.
19
-     *
20
-     * @param string $value      String value
21
-     * @param int    $string_tag Syntax choice
22
-     */
23
-    public function __construct(string $value,
24
-        int $string_tag = DirectoryString::UTF8)
25
-    {
26
-        $this->_oid = AttributeType::OID_TITLE;
27
-        parent::__construct($value, $string_tag);
28
-    }
17
+	/**
18
+	 * Constructor.
19
+	 *
20
+	 * @param string $value      String value
21
+	 * @param int    $string_tag Syntax choice
22
+	 */
23
+	public function __construct(string $value,
24
+		int $string_tag = DirectoryString::UTF8)
25
+	{
26
+		$this->_oid = AttributeType::OID_TITLE;
27
+		parent::__construct($value, $string_tag);
28
+	}
29 29
 }
Please login to merge, or discard this patch.
lib/X501/ASN1/AttributeValue/Feature/PrintableStringValue.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -17,72 +17,72 @@
 block discarded – undo
17 17
  */
18 18
 abstract class PrintableStringValue extends AttributeValue
19 19
 {
20
-    /**
21
-     * String value.
22
-     *
23
-     * @var string
24
-     */
25
-    protected $_string;
20
+	/**
21
+	 * String value.
22
+	 *
23
+	 * @var string
24
+	 */
25
+	protected $_string;
26 26
 
27
-    /**
28
-     * Constructor.
29
-     *
30
-     * @param string $value String value
31
-     */
32
-    public function __construct(string $value)
33
-    {
34
-        $this->_string = $value;
35
-    }
27
+	/**
28
+	 * Constructor.
29
+	 *
30
+	 * @param string $value String value
31
+	 */
32
+	public function __construct(string $value)
33
+	{
34
+		$this->_string = $value;
35
+	}
36 36
 
37
-    /**
38
-     * {@inheritdoc}
39
-     *
40
-     * @return self
41
-     */
42
-    public static function fromASN1(UnspecifiedType $el): AttributeValue
43
-    {
44
-        return new static($el->asPrintableString()->string());
45
-    }
37
+	/**
38
+	 * {@inheritdoc}
39
+	 *
40
+	 * @return self
41
+	 */
42
+	public static function fromASN1(UnspecifiedType $el): AttributeValue
43
+	{
44
+		return new static($el->asPrintableString()->string());
45
+	}
46 46
 
47
-    /**
48
-     * {@inheritdoc}
49
-     */
50
-    public function toASN1(): Element
51
-    {
52
-        return new PrintableString($this->_string);
53
-    }
47
+	/**
48
+	 * {@inheritdoc}
49
+	 */
50
+	public function toASN1(): Element
51
+	{
52
+		return new PrintableString($this->_string);
53
+	}
54 54
 
55
-    /**
56
-     * {@inheritdoc}
57
-     */
58
-    public function stringValue(): string
59
-    {
60
-        return $this->_string;
61
-    }
55
+	/**
56
+	 * {@inheritdoc}
57
+	 */
58
+	public function stringValue(): string
59
+	{
60
+		return $this->_string;
61
+	}
62 62
 
63
-    /**
64
-     * {@inheritdoc}
65
-     */
66
-    public function equalityMatchingRule(): MatchingRule
67
-    {
68
-        // default to caseIgnoreMatch
69
-        return new CaseIgnoreMatch(Element::TYPE_PRINTABLE_STRING);
70
-    }
63
+	/**
64
+	 * {@inheritdoc}
65
+	 */
66
+	public function equalityMatchingRule(): MatchingRule
67
+	{
68
+		// default to caseIgnoreMatch
69
+		return new CaseIgnoreMatch(Element::TYPE_PRINTABLE_STRING);
70
+	}
71 71
 
72
-    /**
73
-     * {@inheritdoc}
74
-     */
75
-    public function rfc2253String(): string
76
-    {
77
-        return DNParser::escapeString($this->_transcodedString());
78
-    }
72
+	/**
73
+	 * {@inheritdoc}
74
+	 */
75
+	public function rfc2253String(): string
76
+	{
77
+		return DNParser::escapeString($this->_transcodedString());
78
+	}
79 79
 
80
-    /**
81
-     * {@inheritdoc}
82
-     */
83
-    protected function _transcodedString(): string
84
-    {
85
-        // PrintableString maps directly to UTF-8
86
-        return $this->_string;
87
-    }
80
+	/**
81
+	 * {@inheritdoc}
82
+	 */
83
+	protected function _transcodedString(): string
84
+	{
85
+		// PrintableString maps directly to UTF-8
86
+		return $this->_string;
87
+	}
88 88
 }
Please login to merge, or discard this patch.