Passed
Push — master ( c00213...72c41f )
by Ivan
03:10
created
src/structures/CRL.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
                     'children' => [
20 20
                         'version' => [
21 21
                             'tag' => ASN1::TYPE_INTEGER,
22
-                            'map' => [1=>'v1','v2','v3']
22
+                            'map' => [ 1=>'v1', 'v2', 'v3' ]
23 23
                         ],
24 24
                         'signature' => Common::AlgorithmIdentifier(),
25 25
                         'issuer' => Common::RDNSequence(),
Please login to merge, or discard this patch.
src/structures/Certificate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
                             'name' => 0,
22 22
                             'implicit' => false,
23 23
                             'tag' => ASN1::TYPE_INTEGER,
24
-                            'map' => [1=>'v1','v2','v3']
24
+                            'map' => [ 1=>'v1', 'v2', 'v3' ]
25 25
                         ],
26 26
                         'serialNumber' => [
27 27
                             'tag' => ASN1::TYPE_INTEGER,
Please login to merge, or discard this patch.
src/structures/OCSPRequest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
                     [
23 23
                         'reqCert' => [
24 24
                             'hashAlgorithm' => [
25
-                                'algorithm' => ASN1::$oids[strtolower($algorithm)] ?? ASN1::$oids['md5']
25
+                                'algorithm' => ASN1::$oids[ strtolower($algorithm) ] ?? ASN1::$oids[ 'md5' ]
26 26
                             ],
27 27
                             'issuerNameHash' => $issuerNameHash,
28 28
                             'issuerKeyHash' => $issuerKeyHash,
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
                             'tag' => ASN1::TYPE_INTEGER,
48 48
                             'name' => 0,
49 49
                             'implicit' => false,
50
-                            'map' => [1=>'v1'],
50
+                            'map' => [ 1=>'v1' ],
51 51
                             'optional' => true
52 52
                         ],
53 53
                         'requestorName' => [
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
                                             ],
78 78
                                         ]
79 79
                                     ],
80
-                                    'extensions' => Common::extensions() + ['name' => 0, 'implicit' => false, 'optional' => true ]
80
+                                    'extensions' => Common::extensions() + [ 'name' => 0, 'implicit' => false, 'optional' => true ]
81 81
                                 ]
82 82
                             ]
83 83
                         ],
84
-                        'extensions' => Common::extensions() + ['name' => 2, 'implicit' => false, 'optional' => true ]
84
+                        'extensions' => Common::extensions() + [ 'name' => 2, 'implicit' => false, 'optional' => true ]
85 85
                     ]
86 86
                 ],
87 87
                 'signature' => [
Please login to merge, or discard this patch.
src/structures/TimestampResponse.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -85,11 +85,11 @@
 block discarded – undo
85 85
                 'messageImprint' => [
86 86
                     'tag' => ASN1::TYPE_SEQUENCE,
87 87
                     'children' => [
88
-                       'hashAlgorithm' => Common::AlgorithmIdentifier(),
89
-                       'hashedMessage' => [
88
+                        'hashAlgorithm' => Common::AlgorithmIdentifier(),
89
+                        'hashedMessage' => [
90 90
                             'tag' => ASN1::TYPE_OCTET_STRING
91 91
                             //'optional' => true // non-optional
92
-                       ]
92
+                        ]
93 93
                     ]
94 94
                 ],
95 95
                 'serialNumber' => ['tag' => ASN1::TYPE_INTEGER, 'base' => 16, 'optional' => true ], // non-optional
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
                     'tag' => ASN1::TYPE_SEQUENCE,
44 44
                     'optional' => true,
45 45
                     'children' => [
46
-                        'contentType' => ['tag' => ASN1::TYPE_OBJECT_IDENTIFIER ],
46
+                        'contentType' => [ 'tag' => ASN1::TYPE_OBJECT_IDENTIFIER ],
47 47
                         'signedData' => [
48 48
                             'name' => 0,
49 49
                             'tag' => ASN1::TYPE_SEQUENCE,
50 50
                             'children' => [
51
-                                'version' => ['tag' => ASN1::TYPE_INTEGER ],
51
+                                'version' => [ 'tag' => ASN1::TYPE_INTEGER ],
52 52
                                 'algorithms' => [
53 53
                                     'tag' => ASN1::TYPE_SET,
54 54
                                     'children' => [
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                                     'tag' => ASN1::TYPE_SEQUENCE,
60 60
                                     'optional' => true,
61 61
                                     'children' => [
62
-                                        'contentType' => ['tag' => ASN1::TYPE_OBJECT_IDENTIFIER ],
62
+                                        'contentType' => [ 'tag' => ASN1::TYPE_OBJECT_IDENTIFIER ],
63 63
                                         'data' => [
64 64
                                             'name' => 0,
65 65
                                             'tag' => ASN1::TYPE_OCTET_STRING,
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
         return [
81 81
             'tag' => ASN1::TYPE_SEQUENCE,
82 82
             'children' => [
83
-                'version' => ['tag' => ASN1::TYPE_INTEGER, 'map' => [1 => 'v1','v2','v3'] ],
84
-                'policy' =>  ['tag' => ASN1::TYPE_OBJECT_IDENTIFIER, 'optional' => true ],
83
+                'version' => [ 'tag' => ASN1::TYPE_INTEGER, 'map' => [ 1 => 'v1', 'v2', 'v3' ] ],
84
+                'policy' =>  [ 'tag' => ASN1::TYPE_OBJECT_IDENTIFIER, 'optional' => true ],
85 85
                 'messageImprint' => [
86 86
                     'tag' => ASN1::TYPE_SEQUENCE,
87 87
                     'children' => [
@@ -92,15 +92,15 @@  discard block
 block discarded – undo
92 92
                        ]
93 93
                     ]
94 94
                 ],
95
-                'serialNumber' => ['tag' => ASN1::TYPE_INTEGER, 'base' => 16, 'optional' => true ], // non-optional
96
-                'genTime' => ['tag' => ASN1::TYPE_GENERALIZED_TIME], // GeneralizedTime (non-optional]
95
+                'serialNumber' => [ 'tag' => ASN1::TYPE_INTEGER, 'base' => 16, 'optional' => true ], // non-optional
96
+                'genTime' => [ 'tag' => ASN1::TYPE_GENERALIZED_TIME ], // GeneralizedTime (non-optional]
97 97
                 'accuracy' => [
98 98
                     'tag' => ASN1::TYPE_SEQUENCE,
99 99
                     'optional' => true,
100 100
                     'children' => [
101
-                        'seconds' => ['tag' => ASN1::TYPE_ANY, 'optional' => true ],
102
-                        'millis' => ['tag' => ASN1::TYPE_ANY, 'optional' => true ],
103
-                        'micros' => ['tag' => ASN1::TYPE_ANY, 'optional' => true ],
101
+                        'seconds' => [ 'tag' => ASN1::TYPE_ANY, 'optional' => true ],
102
+                        'millis' => [ 'tag' => ASN1::TYPE_ANY, 'optional' => true ],
103
+                        'micros' => [ 'tag' => ASN1::TYPE_ANY, 'optional' => true ],
104 104
                     ]
105 105
                 ],
106 106
                 'ordering' => [
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
                     'tag' => ASN1::TYPE_INTEGER,
112 112
                     'optional' => true
113 113
                 ],
114
-                'tsa' => ['tag' => ASN1::TYPE_ANY_DER, 'optional' => true, 'name' => 0], // [0] GeneralName
115
-                'extensions' => ['tag' => ASN1::TYPE_ANY, 'optional' => true, 'name' => 1] // [0] GeneralName
114
+                'tsa' => [ 'tag' => ASN1::TYPE_ANY_DER, 'optional' => true, 'name' => 0 ], // [0] GeneralName
115
+                'extensions' => [ 'tag' => ASN1::TYPE_ANY, 'optional' => true, 'name' => 1 ] // [0] GeneralName
116 116
             ]
117 117
         ];
118 118
     }
Please login to merge, or discard this patch.
src/structures/TimestampRequest.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -107,10 +107,10 @@
 block discarded – undo
107 107
                 'messageImprint' => [
108 108
                     'tag' => ASN1::TYPE_SEQUENCE,
109 109
                     'children' => [
110
-                       'hashAlgorithm' => Common::AlgorithmIdentifier(),
111
-                       'hashedMessage' => [
110
+                        'hashAlgorithm' => Common::AlgorithmIdentifier(),
111
+                        'hashedMessage' => [
112 112
                             'tag' => ASN1::TYPE_OCTET_STRING
113
-                       ]
113
+                        ]
114 114
                     ]
115 115
                 ],
116 116
                 'nonce' => [
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public static function generateFromData($data, $nonce = true, $requireCert = false, $alg = 'sha1', $policy = null)
35 35
     {
36
-        if (!in_array($alg, ['sha1', 'sha256', 'sha384', 'sha512', 'md5'])) {
36
+        if (!in_array($alg, [ 'sha1', 'sha256', 'sha384', 'sha512', 'md5' ])) {
37 37
             throw new ASN1Exception('Unsupported hash algorithm');
38 38
         }
39 39
         $hash = hash($alg, $data, true);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public static function generateFromHash($data, $nonce = true, $requireCert = false, $alg = 'sha1', $policy = null)
70 70
     {
71
-        if (!in_array($alg, ['sha1', 'sha256', 'sha384', 'sha512', 'md5'])) {
71
+        if (!in_array($alg, [ 'sha1', 'sha256', 'sha384', 'sha512', 'md5' ])) {
72 72
             throw new ASN1Exception('Unsupported hash algorithm');
73 73
         }
74 74
         if ($nonce === true) {
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             'children' => [
100 100
                 'version' => [
101 101
                     'tag' => ASN1::TYPE_INTEGER,
102
-                    'map' => [1=>'v1','v2','v3']
102
+                    'map' => [ 1=>'v1', 'v2', 'v3' ]
103 103
                 ],
104 104
                 'reqPolicy' => [
105 105
                     'tag' => ASN1::TYPE_OBJECT_IDENTIFIER,
Please login to merge, or discard this patch.
src/structures/Structure.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,10 +65,10 @@
 block discarded – undo
65 65
             new \RecursiveArrayIterator($this->toArray()),
66 66
             \RecursiveIteratorIterator::LEAVES_ONLY
67 67
         );
68
-        $result = [];
68
+        $result = [ ];
69 69
         foreach ($iterator as $k => $v) {
70 70
             if (strlen($v)) {
71
-                $result[] = str_repeat(' ', $iterator->getDepth()) . $v;
71
+                $result[ ] = str_repeat(' ', $iterator->getDepth()).$v;
72 72
             }
73 73
         }
74 74
         return implode("\r\n", $result);
Please login to merge, or discard this patch.
src/structures/OCSPResponse.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
     public function subject()
13 13
     {
14 14
         $map = static::map();
15
-        $map['children']['responseBytes']['children']['response']['map']['children']['tbsResponseData']['tag'] = ASN1::TYPE_ANY_DER;
15
+        $map[ 'children' ][ 'responseBytes' ][ 'children' ][ 'response' ][ 'map' ][ 'children' ][ 'tbsResponseData' ][ 'tag' ] = ASN1::TYPE_ANY_DER;
16 16
         $temp = $this->data->map($map);
17
-        return $temp['responseBytes']['response']['tbsResponseData'];
17
+        return $temp[ 'responseBytes' ][ 'response' ][ 'tbsResponseData' ];
18 18
     }
19 19
 
20 20
     public static function map()
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                                                 'tag' => ASN1::TYPE_INTEGER,
57 57
                                                 'name' => 0,
58 58
                                                 'implicit' => false,
59
-                                                'map' => [1=>'v1'],
59
+                                                'map' => [ 1=>'v1' ],
60 60
                                                 'optional' => true
61 61
                                             ],
62 62
                                             'responderID' => [
Please login to merge, or discard this patch.
src/Encoder.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
      */
19 19
     public static function encode($source, $mapping)
20 20
     {
21
-        if (isset($mapping['default']) && $source === $mapping['default']) {
21
+        if (isset($mapping[ 'default' ]) && $source === $mapping[ 'default' ]) {
22 22
             return '';
23 23
         }
24 24
 
25
-        $tag = $mapping['tag'];
25
+        $tag = $mapping[ 'tag' ];
26 26
         switch ($tag) {
27 27
             case ASN1::TYPE_SET:
28 28
             case ASN1::TYPE_SEQUENCE:
29 29
                 $tag |= 0x20; // set the constructed bit
30 30
                 $value = '';
31
-                if (isset($mapping['min']) && isset($mapping['max'])) {
32
-                    $child = $mapping['children'];
31
+                if (isset($mapping[ 'min' ]) && isset($mapping[ 'max' ])) {
32
+                    $child = $mapping[ 'children' ];
33 33
                     foreach ($source as $content) {
34 34
                         $temp = static::encode($content, $child);
35 35
                         if ($temp === false) {
@@ -39,23 +39,23 @@  discard block
 block discarded – undo
39 39
                     }
40 40
                     break;
41 41
                 }
42
-                if (isset($mapping['repeat'])) {
42
+                if (isset($mapping[ 'repeat' ])) {
43 43
                     foreach ($source as $content) {
44
-                        $temp = static::encode($content, $mapping['repeat']);
44
+                        $temp = static::encode($content, $mapping[ 'repeat' ]);
45 45
                         if ($temp === false) {
46 46
                             return false;
47 47
                         }
48 48
                         $value .= $temp;
49 49
                     }
50 50
                 } else {
51
-                    foreach ($mapping['children'] as $key => $child) {
51
+                    foreach ($mapping[ 'children' ] as $key => $child) {
52 52
                         if (!array_key_exists($key, $source)) {
53
-                            if (!isset($child['optional'])) {
53
+                            if (!isset($child[ 'optional' ])) {
54 54
                                 return false;
55 55
                             }
56 56
                             continue;
57 57
                         }
58
-                        $temp = static::encode($source[$key], $child);
58
+                        $temp = static::encode($source[ $key ], $child);
59 59
                         if ($temp === false) {
60 60
                             return false;
61 61
                         }
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
                 break;
69 69
             case ASN1::TYPE_CHOICE:
70 70
                 $temp = false;
71
-                foreach ($mapping['children'] as $key => $child) {
72
-                    if (!isset($source[$key])) {
71
+                foreach ($mapping[ 'children' ] as $key => $child) {
72
+                    if (!isset($source[ $key ])) {
73 73
                         continue;
74 74
                     }
75
-                    $temp = static::encode($source[$key], $child);
75
+                    $temp = static::encode($source[ $key ], $child);
76 76
                     if ($temp === false) {
77 77
                         return false;
78 78
                     }
@@ -83,17 +83,17 @@  discard block
 block discarded – undo
83 83
                 return $temp;
84 84
             case ASN1::TYPE_INTEGER:
85 85
             case ASN1::TYPE_ENUMERATED:
86
-                if (!isset($mapping['mapping']) && isset($mapping['base']) && $mapping['base'] === 16) {
86
+                if (!isset($mapping[ 'mapping' ]) && isset($mapping[ 'base' ]) && $mapping[ 'base' ] === 16) {
87 87
                     $value = hex2bin($source);
88 88
                 } else {
89
-                    if (!isset($mapping['mapping'])) {
90
-                        $value = ASN1::toBase256($source, isset($mapping['base']) ? $mapping['base'] : 10);
89
+                    if (!isset($mapping[ 'mapping' ])) {
90
+                        $value = ASN1::toBase256($source, isset($mapping[ 'base' ]) ? $mapping[ 'base' ] : 10);
91 91
                     } else {
92
-                        $value = array_search($source, $mapping['mapping']);
92
+                        $value = array_search($source, $mapping[ 'mapping' ]);
93 93
                         if ($value === false) {
94 94
                             return false;
95 95
                         }
96
-                        $value = ASN1::toBase256($value, isset($mapping['base']) ? (int)$mapping['base'] : 10);
96
+                        $value = ASN1::toBase256($value, isset($mapping[ 'base' ]) ? (int) $mapping[ 'base' ] : 10);
97 97
                     }
98 98
                 }
99 99
                 if (!strlen($value)) {
@@ -102,24 +102,24 @@  discard block
 block discarded – undo
102 102
                 break;
103 103
             case ASN1::TYPE_UTC_TIME:
104 104
             case ASN1::TYPE_GENERALIZED_TIME:
105
-                $format = $mapping['tag'] == ASN1::TYPE_UTC_TIME ? 'y' : 'Y';
106
-                $format.= 'mdHis';
107
-                $value = @gmdate($format, strtotime($source)) . 'Z';
105
+                $format = $mapping[ 'tag' ] == ASN1::TYPE_UTC_TIME ? 'y' : 'Y';
106
+                $format .= 'mdHis';
107
+                $value = @gmdate($format, strtotime($source)).'Z';
108 108
                 break;
109 109
             case ASN1::TYPE_BIT_STRING:
110
-                if (isset($mapping['mapping'])) {
111
-                    $mcnt = count($mapping['mapping']);
110
+                if (isset($mapping[ 'mapping' ])) {
111
+                    $mcnt = count($mapping[ 'mapping' ]);
112 112
                     $bits = array_fill(0, $mcnt, 0);
113 113
                     $size = 0;
114 114
                     for ($i = 0; $i < $mcnt; $i++) {
115
-                        if (in_array($mapping['mapping'][$i], $source)) {
116
-                            $bits[$i] = 1;
115
+                        if (in_array($mapping[ 'mapping' ][ $i ], $source)) {
116
+                            $bits[ $i ] = 1;
117 117
                             $size = $i;
118 118
                         }
119 119
                     }
120 120
 
121
-                    if (isset($mapping['min']) && $mapping['min'] >= 1 && $size < $mapping['min']) {
122
-                        $size = $mapping['min'] - 1;
121
+                    if (isset($mapping[ 'min' ]) && $mapping[ 'min' ] >= 1 && $size < $mapping[ 'min' ]) {
122
+                        $size = $mapping[ 'min' ] - 1;
123 123
                     }
124 124
 
125 125
                     $offset = 8 - (($size + 1) & 7);
@@ -128,23 +128,23 @@  discard block
 block discarded – undo
128 128
                     $value = chr($offset);
129 129
 
130 130
                     for ($i = $size + 1; $i < $mcnt; $i++) {
131
-                        unset($bits[$i]);
131
+                        unset($bits[ $i ]);
132 132
                     }
133 133
 
134 134
                     $bits = implode('', array_pad($bits, $size + $offset + 1, 0));
135 135
                     $bytes = explode(' ', rtrim(chunk_split($bits, 8, ' ')));
136 136
                     foreach ($bytes as $byte) {
137
-                        $value.= chr((int)bindec($byte));
137
+                        $value .= chr((int) bindec($byte));
138 138
                     }
139 139
 
140 140
                     break;
141 141
                 }
142 142
                 // default to octet string if no mapping is present
143 143
             case ASN1::TYPE_OCTET_STRING:
144
-                $value = isset($mapping['raw']) && $mapping['raw'] ? $source : base64_decode($source);
144
+                $value = isset($mapping[ 'raw' ]) && $mapping[ 'raw' ] ? $source : base64_decode($source);
145 145
                 break;
146 146
             case ASN1::TYPE_OBJECT_IDENTIFIER:
147
-                if (!isset($source) && $mapping['optional']) {
147
+                if (!isset($source) && $mapping[ 'optional' ]) {
148 148
                     return;
149 149
                 }
150 150
                 $oid = preg_match('(^(\d+\.?)+$)', $source) ? $source : ASN1::TextToOID($source);
@@ -152,20 +152,20 @@  discard block
 block discarded – undo
152 152
                     throw new ASN1Exception('Invalid OID');
153 153
                 }
154 154
                 $parts = explode('.', $oid);
155
-                $value = chr(40 * $parts[0] + $parts[1]);
155
+                $value = chr(40 * $parts[ 0 ] + $parts[ 1 ]);
156 156
                 $pcnt = count($parts);
157 157
                 for ($i = 2; $i < $pcnt; $i++) {
158 158
                     $temp = '';
159
-                    if (!$parts[$i]) {
159
+                    if (!$parts[ $i ]) {
160 160
                         $temp = "\0";
161 161
                     } else {
162
-                        while ($parts[$i]) {
163
-                            $temp = chr(0x80 | ($parts[$i] & 0x7F)) . $temp;
164
-                            $parts[$i] >>= 7;
162
+                        while ($parts[ $i ]) {
163
+                            $temp = chr(0x80 | ($parts[ $i ] & 0x7F)).$temp;
164
+                            $parts[ $i ] >>= 7;
165 165
                         }
166
-                        $temp[strlen($temp) - 1] = $temp[strlen($temp) - 1] & chr(0x7F);
166
+                        $temp[ strlen($temp) - 1 ] = $temp[ strlen($temp) - 1 ] & chr(0x7F);
167 167
                     }
168
-                    $value.= $temp;
168
+                    $value .= $temp;
169 169
                 }
170 170
                 break;
171 171
             case ASN1::TYPE_ANY:
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
         }
207 207
 
208 208
         $length = static::length(strlen($value));
209
-        if (isset($mapping['name'])) {
210
-            if (isset($mapping['implicit']) && $mapping['implicit']) {
211
-                $tag = ((ASN1::CLASS_CONTEXT_SPECIFIC ?? 2) << 6) | (ord($value[0]) & 0x20) | $mapping['name'];
212
-                return chr($tag) . $length . $value;
209
+        if (isset($mapping[ 'name' ])) {
210
+            if (isset($mapping[ 'implicit' ]) && $mapping[ 'implicit' ]) {
211
+                $tag = ((ASN1::CLASS_CONTEXT_SPECIFIC ?? 2) << 6) | (ord($value[ 0 ]) & 0x20) | $mapping[ 'name' ];
212
+                return chr($tag).$length.$value;
213 213
             } else {
214
-                $value = chr($tag) . $length . $value;
215
-                return chr(((ASN1::CLASS_CONTEXT_SPECIFIC ?? 2) << 6) | 0x20 | $mapping['name']) . static::length(strlen($value)) . $value;
214
+                $value = chr($tag).$length.$value;
215
+                return chr(((ASN1::CLASS_CONTEXT_SPECIFIC ?? 2) << 6) | 0x20 | $mapping[ 'name' ]).static::length(strlen($value)).$value;
216 216
             }
217 217
         }
218
-        return chr($tag) . $length . $value;
218
+        return chr($tag).$length.$value;
219 219
     }
220 220
 
221 221
     protected static function length($length)
Please login to merge, or discard this patch.
src/Decoder.php 1 patch
Spacing   +147 added lines, -148 removed lines patch added patch discarded remove patch
@@ -100,36 +100,35 @@  discard block
 block discarded – undo
100 100
     }
101 101
     protected function decode($header)
102 102
     {
103
-        $contents = $header['content_length'] > 0 ?
104
-            $this->reader->chunk($header['content_start'], $header['content_length']) :
105
-            '';
106
-        if ($header['class'] !== ASN1::CLASS_UNIVERSAL) {
103
+        $contents = $header[ 'content_length' ] > 0 ?
104
+            $this->reader->chunk($header[ 'content_start' ], $header[ 'content_length' ]) : '';
105
+        if ($header[ 'class' ] !== ASN1::CLASS_UNIVERSAL) {
107 106
             return $contents;
108 107
         }
109
-        switch ($header['tag']) {
108
+        switch ($header[ 'tag' ]) {
110 109
             case ASN1::TYPE_BOOLEAN:
111
-                return (bool)ord($contents[0]);
110
+                return (bool) ord($contents[ 0 ]);
112 111
             case ASN1::TYPE_INTEGER:
113 112
                 return ASN1::fromBase256($contents);
114 113
             case ASN1::TYPE_ENUMERATED:
115
-                return (int)base_convert(ASN1::fromBase256($contents), 2, 10);
114
+                return (int) base_convert(ASN1::fromBase256($contents), 2, 10);
116 115
             case ASN1::TYPE_REAL:
117 116
                 // TODO: read the specs
118 117
                 return false;
119 118
             case ASN1::TYPE_BIT_STRING:
120
-                if ($header['constructed']) {
119
+                if ($header[ 'constructed' ]) {
121 120
                     $temp = static::fromString($contents)->values();
122 121
                     $real = '';
123 122
                     for ($i = 0; $i < count($temp) - 1; $i++) {
124
-                        $real .= $temp['value'];
123
+                        $real .= $temp[ 'value' ];
125 124
                     }
126
-                    return $temp[count($temp) - 1]['value'][0] . $real . substr($temp[$i]['value'], 1);
125
+                    return $temp[ count($temp) - 1 ][ 'value' ][ 0 ].$real.substr($temp[ $i ][ 'value' ], 1);
127 126
                 }
128 127
                 return $contents;
129 128
             case ASN1::TYPE_OCTET_STRING:
130
-                if ($header['constructed']) {
131
-                    return implode('', array_map(function ($v) {
132
-                        return $v['value'];
129
+                if ($header[ 'constructed' ]) {
130
+                    return implode('', array_map(function($v) {
131
+                        return $v[ 'value' ];
133 132
                     }, static::fromString($contents)->values()));
134 133
                 }
135 134
                 return $contents;
@@ -137,14 +136,14 @@  discard block
 block discarded – undo
137 136
                 return null;
138 137
             case ASN1::TYPE_UTC_TIME:
139 138
                 $format = 'YmdHis';
140
-                $matches = [];
139
+                $matches = [ ];
141 140
                 if (preg_match('#^(\d{10})(Z|[+-]\d{4})$#', $contents, $matches)) {
142
-                    $contents = $matches[1] . '00' . $matches[2];
141
+                    $contents = $matches[ 1 ].'00'.$matches[ 2 ];
143 142
                 }
144 143
                 $prefix = substr($contents, 0, 2) >= 50 ? '19' : '20';
145
-                $contents = $prefix . $contents;
146
-                if ($contents[strlen($contents) - 1] == 'Z') {
147
-                    $contents = substr($contents, 0, -1) . '+0000';
144
+                $contents = $prefix.$contents;
145
+                if ($contents[ strlen($contents) - 1 ] == 'Z') {
146
+                    $contents = substr($contents, 0, -1).'+0000';
148 147
                 }
149 148
                 if (strpos($contents, '-') !== false || strpos($contents, '+') !== false) {
150 149
                     $format .= 'O';
@@ -156,8 +155,8 @@  discard block
 block discarded – undo
156 155
                 if (strpos($contents, '.') !== false) {
157 156
                     $format .= '.u';
158 157
                 }
159
-                if ($contents[strlen($contents) - 1] == 'Z') {
160
-                    $contents = substr($contents, 0, -1) . '+0000';
158
+                if ($contents[ strlen($contents) - 1 ] == 'Z') {
159
+                    $contents = substr($contents, 0, -1).'+0000';
161 160
                 }
162 161
                 if (strpos($contents, '-') !== false || strpos($contents, '+') !== false) {
163 162
                     $format .= 'O';
@@ -165,16 +164,16 @@  discard block
 block discarded – undo
165 164
                 $result = @DateTime::createFromFormat($format, $contents);
166 165
                 return $result ? $result->getTimestamp() : false;
167 166
             case ASN1::TYPE_OBJECT_IDENTIFIER:
168
-                $temp = ord($contents[0]);
167
+                $temp = ord($contents[ 0 ]);
169 168
                 $real = sprintf('%d.%d', floor($temp / 40), $temp % 40);
170 169
                 $obid = 0;
171 170
                 // process septets
172 171
                 for ($i = 1; $i < strlen($contents); $i++) {
173
-                    $temp = ord($contents[$i]);
172
+                    $temp = ord($contents[ $i ]);
174 173
                     $obid <<= 7;
175 174
                     $obid |= $temp & 0x7F;
176 175
                     if (~$temp & 0x80) {
177
-                        $real .= '.' . $obid;
176
+                        $real .= '.'.$obid;
178 177
                         $obid = 0;
179 178
                     }
180 179
                 }
@@ -191,51 +190,51 @@  discard block
 block discarded – undo
191 190
      */
192 191
     public function structure($max = null)
193 192
     {
194
-        $skeleton = [];
193
+        $skeleton = [ ];
195 194
         while (!$this->reader->eof() && ($max === null || $this->reader->pos() < $max)) {
196 195
             $header = $this->header();
197
-            if ($header['class'] === 0 && $header['tag'] === 0) {
196
+            if ($header[ 'class' ] === 0 && $header[ 'tag' ] === 0) {
198 197
                 if ($max === null) {
199 198
                     break;
200 199
                 } else {
201 200
                     continue;
202 201
                 }
203 202
             }
204
-            if ($header['class'] !== ASN1::CLASS_UNIVERSAL && $header['constructed']) {
205
-                $header['children'] = $this->structure($header['length'] ? $header['start'] + $header['length'] - 1 : null);
206
-                if ($header['length'] === null) {
203
+            if ($header[ 'class' ] !== ASN1::CLASS_UNIVERSAL && $header[ 'constructed' ]) {
204
+                $header[ 'children' ] = $this->structure($header[ 'length' ] ? $header[ 'start' ] + $header[ 'length' ] - 1 : null);
205
+                if ($header[ 'length' ] === null) {
207 206
                     $this->reader->byte();
208
-                    $header['length'] = $this->reader->pos() - $header['start'];
209
-                    $header['content_length'] = $this->reader->pos() - $header['content_start'];
207
+                    $header[ 'length' ] = $this->reader->pos() - $header[ 'start' ];
208
+                    $header[ 'content_length' ] = $this->reader->pos() - $header[ 'content_start' ];
210 209
                 }
211
-                $skeleton[] = $header;
210
+                $skeleton[ ] = $header;
212 211
             } else {
213
-                if ($header['class'] === ASN1::CLASS_UNIVERSAL &&
214
-                    in_array($header['tag'], [ASN1::TYPE_SET, ASN1::TYPE_SEQUENCE])
212
+                if ($header[ 'class' ] === ASN1::CLASS_UNIVERSAL &&
213
+                    in_array($header[ 'tag' ], [ ASN1::TYPE_SET, ASN1::TYPE_SEQUENCE ])
215 214
                 ) {
216
-                    $header['children'] = $this->structure($header['length'] ? $header['start'] + $header['length'] - 1 : null);
217
-                    if ($header['length'] === null) {
215
+                    $header[ 'children' ] = $this->structure($header[ 'length' ] ? $header[ 'start' ] + $header[ 'length' ] - 1 : null);
216
+                    if ($header[ 'length' ] === null) {
218 217
                         $this->reader->byte();
219
-                        $header['length'] = $this->reader->pos() - $header['start'];
220
-                        $header['content_length'] = $this->reader->pos() - $header['content_start'];
218
+                        $header[ 'length' ] = $this->reader->pos() - $header[ 'start' ];
219
+                        $header[ 'content_length' ] = $this->reader->pos() - $header[ 'content_start' ];
221 220
                     }
222 221
                 } else {
223
-                    if ($header['length'] === null) {
222
+                    if ($header[ 'length' ] === null) {
224 223
                         $this->reader->readUntil(chr(0).chr(0));
225
-                        $header['length'] = $this->reader->pos() - $header['start'];
226
-                        $header['content_length'] = $this->reader->pos() - $header['content_start'];
224
+                        $header[ 'length' ] = $this->reader->pos() - $header[ 'start' ];
225
+                        $header[ 'content_length' ] = $this->reader->pos() - $header[ 'content_start' ];
227 226
                     } else {
228
-                        if ($header['content_length'] > 0) {
229
-                            $this->reader->bytes($header['content_length']);
227
+                        if ($header[ 'content_length' ] > 0) {
228
+                            $this->reader->bytes($header[ 'content_length' ]);
230 229
                         }
231 230
                     }
232 231
                 }
233
-                if (!isset($header['children'])) {
232
+                if (!isset($header[ 'children' ])) {
234 233
                     $pos = $this->reader->pos();
235
-                    $header['value'] = $this->decode($header);
234
+                    $header[ 'value' ] = $this->decode($header);
236 235
                     $this->reader->seek($pos);
237 236
                 }
238
-                $skeleton[] = $header;
237
+                $skeleton[ ] = $header;
239 238
             }
240 239
         }
241 240
         return $skeleton;
@@ -250,10 +249,10 @@  discard block
 block discarded – undo
250 249
     {
251 250
         $skeleton = $skeleton ?? $this->structure();
252 251
         foreach ($skeleton as $k => $v) {
253
-            if (isset($v['children'])) {
254
-                $skeleton[$k] = $this->values($v['children']);
252
+            if (isset($v[ 'children' ])) {
253
+                $skeleton[ $k ] = $this->values($v[ 'children' ]);
255 254
             } else {
256
-                $skeleton[$k] = $v['value'] ?? null;
255
+                $skeleton[ $k ] = $v[ 'value' ] ?? null;
257 256
             }
258 257
         }
259 258
         return $skeleton;
@@ -270,176 +269,176 @@  discard block
 block discarded – undo
270 269
         if ($skeleton === null && $this->reader->pos() !== 0) {
271 270
             $this->reader->rewind();
272 271
         }
273
-        $skeleton = $skeleton ?? $this->structure()[0];
274
-        if ($skeleton['class'] !== ASN1::CLASS_UNIVERSAL) {
275
-            if ($map['tag'] === ASN1::TYPE_CHOICE) {
276
-                foreach ($map['children'] as $child) {
277
-                    if (isset($child['name']) && (int)$skeleton['tag'] === (int)$child['name']) {
272
+        $skeleton = $skeleton ?? $this->structure()[ 0 ];
273
+        if ($skeleton[ 'class' ] !== ASN1::CLASS_UNIVERSAL) {
274
+            if ($map[ 'tag' ] === ASN1::TYPE_CHOICE) {
275
+                foreach ($map[ 'children' ] as $child) {
276
+                    if (isset($child[ 'name' ]) && (int) $skeleton[ 'tag' ] === (int) $child[ 'name' ]) {
278 277
                         $map = $child;
279
-                        if (isset($child['value']) && $child['value']) {
280
-                            return $child['value'];
278
+                        if (isset($child[ 'value' ]) && $child[ 'value' ]) {
279
+                            return $child[ 'value' ];
281 280
                         }
282 281
                         break;
283 282
                     }
284 283
                 }
285 284
             }
286 285
         }
287
-        if ($skeleton['class'] !== ASN1::CLASS_UNIVERSAL) {
288
-            if (isset($map['implicit']) && $map['implicit']) {
289
-                $skeleton['class'] = ASN1::CLASS_UNIVERSAL;
290
-                $skeleton['tag'] = $map['tag'];
286
+        if ($skeleton[ 'class' ] !== ASN1::CLASS_UNIVERSAL) {
287
+            if (isset($map[ 'implicit' ]) && $map[ 'implicit' ]) {
288
+                $skeleton[ 'class' ] = ASN1::CLASS_UNIVERSAL;
289
+                $skeleton[ 'tag' ] = $map[ 'tag' ];
291 290
             } else {
292
-                $skeleton = $skeleton['children'][0] ?? null;
291
+                $skeleton = $skeleton[ 'children' ][ 0 ] ?? null;
293 292
             }
294 293
         }
295
-        if ($map['tag'] === ASN1::TYPE_CHOICE) {
296
-            foreach ($map['children'] as $child) {
297
-                if ($skeleton['tag'] === $child['tag']) {
294
+        if ($map[ 'tag' ] === ASN1::TYPE_CHOICE) {
295
+            foreach ($map[ 'children' ] as $child) {
296
+                if ($skeleton[ 'tag' ] === $child[ 'tag' ]) {
298 297
                     $map = $child;
299
-                    if (isset($child['value']) && $child['value']) {
300
-                        return $child['value'];
298
+                    if (isset($child[ 'value' ]) && $child[ 'value' ]) {
299
+                        return $child[ 'value' ];
301 300
                     }
302 301
                     break;
303 302
                 }
304 303
             }
305 304
         }
306
-        if (in_array($map['tag'], [ASN1::TYPE_SEQUENCE, ASN1::TYPE_SET]) &&
307
-            in_array($skeleton['tag'], [ASN1::TYPE_SEQUENCE, ASN1::TYPE_SET])) {
308
-            $map['tag'] = $skeleton['tag'];
305
+        if (in_array($map[ 'tag' ], [ ASN1::TYPE_SEQUENCE, ASN1::TYPE_SET ]) &&
306
+            in_array($skeleton[ 'tag' ], [ ASN1::TYPE_SEQUENCE, ASN1::TYPE_SET ])) {
307
+            $map[ 'tag' ] = $skeleton[ 'tag' ];
309 308
         }
310
-        if ($map['tag'] === ASN1::TYPE_ANY && isset($skeleton['tag'])) {
311
-            $map['tag'] = $skeleton['tag'];
309
+        if ($map[ 'tag' ] === ASN1::TYPE_ANY && isset($skeleton[ 'tag' ])) {
310
+            $map[ 'tag' ] = $skeleton[ 'tag' ];
312 311
         }
313
-        if (!in_array($map['tag'], [ASN1::TYPE_ANY, ASN1::TYPE_ANY_RAW, ASN1::TYPE_ANY_SKIP, ASN1::TYPE_ANY_DER]) &&
314
-            $map['tag'] !== $skeleton['tag']
312
+        if (!in_array($map[ 'tag' ], [ ASN1::TYPE_ANY, ASN1::TYPE_ANY_RAW, ASN1::TYPE_ANY_SKIP, ASN1::TYPE_ANY_DER ]) &&
313
+            $map[ 'tag' ] !== $skeleton[ 'tag' ]
315 314
         ) {
316
-            if (!isset($map['optional']) || !$map['optional']) {
317
-                throw new ASN1Exception('Decoded data does not match mapping - ' . $skeleton['tag']);
315
+            if (!isset($map[ 'optional' ]) || !$map[ 'optional' ]) {
316
+                throw new ASN1Exception('Decoded data does not match mapping - '.$skeleton[ 'tag' ]);
318 317
             }
319 318
             return null;
320 319
         } else {
321
-            switch ($map['tag']) {
320
+            switch ($map[ 'tag' ]) {
322 321
                 case ASN1::TYPE_ANY_DER:
323
-                    return $this->reader->chunk($skeleton['start'], $skeleton['length']);
322
+                    return $this->reader->chunk($skeleton[ 'start' ], $skeleton[ 'length' ]);
324 323
                 case ASN1::TYPE_ANY_SKIP:
325 324
                     return null;
326 325
                 case ASN1::TYPE_ANY_RAW:
327
-                    return $skeleton['value'] ?? null;
326
+                    return $skeleton[ 'value' ] ?? null;
328 327
                 case ASN1::TYPE_SET:
329
-                    if (isset($map['repeat'])) {
330
-                        $result = [];
331
-                        foreach ($skeleton['children'] as $v) {
332
-                            $result[] = $this->map($map['repeat'], $v);
328
+                    if (isset($map[ 'repeat' ])) {
329
+                        $result = [ ];
330
+                        foreach ($skeleton[ 'children' ] as $v) {
331
+                            $result[ ] = $this->map($map[ 'repeat' ], $v);
333 332
                         }
334 333
                         return $result;
335 334
                     } else {
336
-                        if (!isset($map['children'])) {
335
+                        if (!isset($map[ 'children' ])) {
337 336
                             return null;
338 337
                         }
339
-                        $temp = $skeleton['children'];
340
-                        $result = [];
338
+                        $temp = $skeleton[ 'children' ];
339
+                        $result = [ ];
341 340
                         // named first
342
-                        foreach ($map['children'] as $k => $v) {
343
-                            if (isset($v['name'])) {
344
-                                $result[$k] = null;
341
+                        foreach ($map[ 'children' ] as $k => $v) {
342
+                            if (isset($v[ 'name' ])) {
343
+                                $result[ $k ] = null;
345 344
                                 foreach ($temp as $kk => $vv) {
346
-                                    if ($vv['class'] !== ASN1::CLASS_UNIVERSAL && (int)$v['name'] === $vv['tag']) {
345
+                                    if ($vv[ 'class' ] !== ASN1::CLASS_UNIVERSAL && (int) $v[ 'name' ] === $vv[ 'tag' ]) {
347 346
                                         try {
348
-                                            if (isset($v['implicit']) && $v['implicit']) {
349
-                                                $vv['class'] = ASN1::CLASS_UNIVERSAL;
350
-                                                $vv['tag'] = $map['tag'];
347
+                                            if (isset($v[ 'implicit' ]) && $v[ 'implicit' ]) {
348
+                                                $vv[ 'class' ] = ASN1::CLASS_UNIVERSAL;
349
+                                                $vv[ 'tag' ] = $map[ 'tag' ];
351 350
                                             } else {
352
-                                                $vv = $vv['children'][0] ?? null;
351
+                                                $vv = $vv[ 'children' ][ 0 ] ?? null;
353 352
                                             }
354
-                                            $result[$k] = $this->map($v, $vv);
355
-                                            unset($temp[$kk]);
353
+                                            $result[ $k ] = $this->map($v, $vv);
354
+                                            unset($temp[ $kk ]);
356 355
                                             break;
357 356
                                         } catch (ASN1Exception $e) {
358 357
                                             // continue trying other children in case of failure
359 358
                                         }
360 359
                                     }
361 360
                                 }
362
-                                if ($result[$k] === null && (!isset($v['optional']) || !$v['optional'])) {
363
-                                    throw new ASN1Exception('Missing tagged type - ' . $k);
361
+                                if ($result[ $k ] === null && (!isset($v[ 'optional' ]) || !$v[ 'optional' ])) {
362
+                                    throw new ASN1Exception('Missing tagged type - '.$k);
364 363
                                 }
365 364
                             }
366 365
                         }
367
-                        foreach ($map['children'] as $k => $v) {
368
-                            if (isset($v['name'])) {
366
+                        foreach ($map[ 'children' ] as $k => $v) {
367
+                            if (isset($v[ 'name' ])) {
369 368
                                 continue;
370 369
                             }
371
-                            $result[$k] = null;
370
+                            $result[ $k ] = null;
372 371
                             foreach ($temp as $kk => $vv) {
373
-                                if ($v['tag'] === $vv['tag'] ||
372
+                                if ($v[ 'tag' ] === $vv[ 'tag' ] ||
374 373
                                     in_array(
375
-                                        $v['tag'],
374
+                                        $v[ 'tag' ],
376 375
                                         [ ASN1::TYPE_ANY, ASN1::TYPE_ANY_DER, ASN1::TYPE_ANY_RAW, ASN1::TYPE_ANY_SKIP, ASN1::TYPE_CHOICE ]
377 376
                                     )
378 377
                                 ) {
379 378
                                     try {
380
-                                        $result[$k] = $this->map($v, $vv);
381
-                                        unset($temp[$kk]);
379
+                                        $result[ $k ] = $this->map($v, $vv);
380
+                                        unset($temp[ $kk ]);
382 381
                                         break;
383 382
                                     } catch (ASN1Exception $e) {
384
-                                        $result[$k] = null;
383
+                                        $result[ $k ] = null;
385 384
                                     }
386 385
                                 }
387 386
                             }
388
-                            if ($result[$k] === null && (!isset($v['optional']) || !$v['optional'])) {
389
-                                throw new ASN1Exception('Decoded data does not match mapping - ' . $k);
387
+                            if ($result[ $k ] === null && (!isset($v[ 'optional' ]) || !$v[ 'optional' ])) {
388
+                                throw new ASN1Exception('Decoded data does not match mapping - '.$k);
390 389
                             }
391 390
                         }
392 391
                         return $result;
393 392
                     }
394 393
                     break;
395 394
                 case ASN1::TYPE_SEQUENCE:
396
-                    if (isset($map['repeat'])) {
397
-                        $result = [];
398
-                        foreach ($skeleton['children'] as $v) {
399
-                            $result[] = $this->map($map['repeat'], $v);
395
+                    if (isset($map[ 'repeat' ])) {
396
+                        $result = [ ];
397
+                        foreach ($skeleton[ 'children' ] as $v) {
398
+                            $result[ ] = $this->map($map[ 'repeat' ], $v);
400 399
                         }
401 400
                         return $result;
402 401
                     } else {
403
-                        if (!isset($map['children'])) {
402
+                        if (!isset($map[ 'children' ])) {
404 403
                             return null;
405 404
                         }
406
-                        $result = [];
407
-                        foreach ($skeleton['children'] as $vv) {
408
-                            foreach ($map['children'] as $k => $v) {
409
-                                if (isset($v['name']) && $vv['class'] !== ASN1::CLASS_UNIVERSAL && (int)$v['name'] === $vv['tag']) {
410
-                                    if (isset($v['implicit']) && $v['implicit']) {
411
-                                        $vv['class'] = ASN1::CLASS_UNIVERSAL;
412
-                                        $vv['tag'] = $map['tag'];
405
+                        $result = [ ];
406
+                        foreach ($skeleton[ 'children' ] as $vv) {
407
+                            foreach ($map[ 'children' ] as $k => $v) {
408
+                                if (isset($v[ 'name' ]) && $vv[ 'class' ] !== ASN1::CLASS_UNIVERSAL && (int) $v[ 'name' ] === $vv[ 'tag' ]) {
409
+                                    if (isset($v[ 'implicit' ]) && $v[ 'implicit' ]) {
410
+                                        $vv[ 'class' ] = ASN1::CLASS_UNIVERSAL;
411
+                                        $vv[ 'tag' ] = $map[ 'tag' ];
413 412
                                     } else {
414
-                                        $vv = $vv['children'][0] ?? null;
413
+                                        $vv = $vv[ 'children' ][ 0 ] ?? null;
415 414
                                     }
416
-                                    $result[$k] = $this->map($v, $vv);
417
-                                    unset($map['children'][$k]);
415
+                                    $result[ $k ] = $this->map($v, $vv);
416
+                                    unset($map[ 'children' ][ $k ]);
418 417
                                     break;
419 418
                                 }
420
-                                if (!isset($v['name']) &&
419
+                                if (!isset($v[ 'name' ]) &&
421 420
                                     (
422
-                                        $v['tag'] === $vv['tag'] ||
421
+                                        $v[ 'tag' ] === $vv[ 'tag' ] ||
423 422
                                         in_array(
424
-                                            $v['tag'],
423
+                                            $v[ 'tag' ],
425 424
                                             [ ASN1::TYPE_ANY, ASN1::TYPE_ANY_DER, ASN1::TYPE_ANY_RAW, ASN1::TYPE_ANY_SKIP, ASN1::TYPE_CHOICE ]
426 425
                                         )
427 426
                                     )
428 427
                                 ) {
429 428
                                     try {
430 429
                                         $temp = $this->map($v, $vv);
431
-                                        $result[$k] = $temp;
432
-                                        unset($map['children'][$k]);
430
+                                        $result[ $k ] = $temp;
431
+                                        unset($map[ 'children' ][ $k ]);
433 432
                                         break;
434 433
                                     } catch (ASN1Exception $e) {
435 434
                                         // continue trying other children in case of failure
436 435
                                     }
437 436
                                 }
438
-                                if (!isset($v['optional']) || !$v['optional']) {
439
-                                    throw new ASN1Exception('Missing type - ' . $k);
437
+                                if (!isset($v[ 'optional' ]) || !$v[ 'optional' ]) {
438
+                                    throw new ASN1Exception('Missing type - '.$k);
440 439
                                 } else {
441
-                                    $result[$k] = null;
442
-                                    unset($map['children'][$k]);
440
+                                    $result[ $k ] = null;
441
+                                    unset($map[ 'children' ][ $k ]);
443 442
                                 }
444 443
                             }
445 444
                         }
@@ -447,45 +446,45 @@  discard block
 block discarded – undo
447 446
                     }
448 447
                     break;
449 448
                 case ASN1::TYPE_OBJECT_IDENTIFIER:
450
-                    return isset($map['resolve']) && $map['resolve'] ? ASN1::OIDtoText($skeleton['value']) : $skeleton['value'];
449
+                    return isset($map[ 'resolve' ]) && $map[ 'resolve' ] ? ASN1::OIDtoText($skeleton[ 'value' ]) : $skeleton[ 'value' ];
451 450
                 case ASN1::TYPE_OCTET_STRING:
452
-                    if (isset($map['der']) && $map['der']) {
453
-                        $temp = static::fromString($skeleton['value']);
454
-                        return isset($map['map']) ? $temp->map($map['map']) : $temp->values();
451
+                    if (isset($map[ 'der' ]) && $map[ 'der' ]) {
452
+                        $temp = static::fromString($skeleton[ 'value' ]);
453
+                        return isset($map[ 'map' ]) ? $temp->map($map[ 'map' ]) : $temp->values();
455 454
                     } else {
456
-                        return isset($map['raw']) && $map['raw'] ? $skeleton['value'] : base64_encode($skeleton['value']);
455
+                        return isset($map[ 'raw' ]) && $map[ 'raw' ] ? $skeleton[ 'value' ] : base64_encode($skeleton[ 'value' ]);
457 456
                     }
458 457
                     break;
459 458
                 case ASN1::TYPE_INTEGER:
460
-                    $base = isset($map['base']) && (int)$map['base'] ? (int)$map['base'] : 10;
459
+                    $base = isset($map[ 'base' ]) && (int) $map[ 'base' ] ? (int) $map[ 'base' ] : 10;
461 460
                     if ($base < 3) {
462
-                        $result = $skeleton['value'];
461
+                        $result = $skeleton[ 'value' ];
463 462
                     } else {
464
-                        if (strlen($skeleton['value']) > 53 && $base === 16) {
463
+                        if (strlen($skeleton[ 'value' ]) > 53 && $base === 16) {
465 464
                             $hex = '';
466
-                            for ($i = strlen($skeleton['value']) - 4; $i >= 0; $i-=4) {
467
-                                $hex .= dechex((int)bindec(substr($skeleton['value'], $i, 4)));
465
+                            for ($i = strlen($skeleton[ 'value' ]) - 4; $i >= 0; $i -= 4) {
466
+                                $hex .= dechex((int) bindec(substr($skeleton[ 'value' ], $i, 4)));
468 467
                             }
469 468
                             $result = strrev($hex);
470 469
                         } else {
471
-                            $temp = base_convert($skeleton['value'], 2, $base);
470
+                            $temp = base_convert($skeleton[ 'value' ], 2, $base);
472 471
                             if ($base === 10) {
473
-                                $temp = (int)$temp;
472
+                                $temp = (int) $temp;
474 473
                             }
475 474
                             $result = $temp;
476 475
                         }
477 476
                     }
478
-                    if (isset($map['map']) && isset($map['map'][$result])) {
479
-                        $result = $map['map'][$result];
477
+                    if (isset($map[ 'map' ]) && isset($map[ 'map' ][ $result ])) {
478
+                        $result = $map[ 'map' ][ $result ];
480 479
                     }
481 480
                     return $result;
482 481
                 case ASN1::TYPE_UTC_TIME:
483 482
                 case ASN1::TYPE_GENERALIZED_TIME:
484
-                    return $skeleton['value'];
483
+                    return $skeleton[ 'value' ];
485 484
                 default:
486
-                    $result = $skeleton['value'];
487
-                    if (isset($map['map']) && isset($map['map'][$result])) {
488
-                        $result = $map['map'][$result];
485
+                    $result = $skeleton[ 'value' ];
486
+                    if (isset($map[ 'map' ]) && isset($map[ 'map' ][ $result ])) {
487
+                        $result = $map[ 'map' ][ $result ];
489 488
                     }
490 489
                     return $result;
491 490
             }
Please login to merge, or discard this patch.