GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — php72 ( 84962a...e2a8e9 )
by Joni
02:36
created
lib/X509/Certificate/Extension/NameConstraintsExtension.php 2 patches
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -17,116 +17,116 @@
 block discarded – undo
17 17
  */
18 18
 class NameConstraintsExtension extends Extension
19 19
 {
20
-    /**
21
-     * Permitted subtrees.
22
-     *
23
-     * @var null|GeneralSubtrees
24
-     */
25
-    protected $_permitted;
20
+	/**
21
+	 * Permitted subtrees.
22
+	 *
23
+	 * @var null|GeneralSubtrees
24
+	 */
25
+	protected $_permitted;
26 26
 
27
-    /**
28
-     * Excluded subtrees.
29
-     *
30
-     * @var null|GeneralSubtrees
31
-     */
32
-    protected $_excluded;
27
+	/**
28
+	 * Excluded subtrees.
29
+	 *
30
+	 * @var null|GeneralSubtrees
31
+	 */
32
+	protected $_excluded;
33 33
 
34
-    /**
35
-     * Constructor.
36
-     *
37
-     * @param bool            $critical
38
-     * @param GeneralSubtrees $permitted
39
-     * @param GeneralSubtrees $excluded
40
-     */
41
-    public function __construct(bool $critical, ?GeneralSubtrees $permitted = null,
42
-        ?GeneralSubtrees $excluded = null)
43
-    {
44
-        parent::__construct(self::OID_NAME_CONSTRAINTS, $critical);
45
-        $this->_permitted = $permitted;
46
-        $this->_excluded = $excluded;
47
-    }
34
+	/**
35
+	 * Constructor.
36
+	 *
37
+	 * @param bool            $critical
38
+	 * @param GeneralSubtrees $permitted
39
+	 * @param GeneralSubtrees $excluded
40
+	 */
41
+	public function __construct(bool $critical, ?GeneralSubtrees $permitted = null,
42
+		?GeneralSubtrees $excluded = null)
43
+	{
44
+		parent::__construct(self::OID_NAME_CONSTRAINTS, $critical);
45
+		$this->_permitted = $permitted;
46
+		$this->_excluded = $excluded;
47
+	}
48 48
 
49
-    /**
50
-     * Whether permitted subtrees are present.
51
-     *
52
-     * @return bool
53
-     */
54
-    public function hasPermittedSubtrees(): bool
55
-    {
56
-        return isset($this->_permitted);
57
-    }
49
+	/**
50
+	 * Whether permitted subtrees are present.
51
+	 *
52
+	 * @return bool
53
+	 */
54
+	public function hasPermittedSubtrees(): bool
55
+	{
56
+		return isset($this->_permitted);
57
+	}
58 58
 
59
-    /**
60
-     * Get permitted subtrees.
61
-     *
62
-     * @throws \LogicException If not set
63
-     *
64
-     * @return GeneralSubtrees
65
-     */
66
-    public function permittedSubtrees(): GeneralSubtrees
67
-    {
68
-        if (!$this->hasPermittedSubtrees()) {
69
-            throw new \LogicException('No permitted subtrees.');
70
-        }
71
-        return $this->_permitted;
72
-    }
59
+	/**
60
+	 * Get permitted subtrees.
61
+	 *
62
+	 * @throws \LogicException If not set
63
+	 *
64
+	 * @return GeneralSubtrees
65
+	 */
66
+	public function permittedSubtrees(): GeneralSubtrees
67
+	{
68
+		if (!$this->hasPermittedSubtrees()) {
69
+			throw new \LogicException('No permitted subtrees.');
70
+		}
71
+		return $this->_permitted;
72
+	}
73 73
 
74
-    /**
75
-     * Whether excluded subtrees are present.
76
-     *
77
-     * @return bool
78
-     */
79
-    public function hasExcludedSubtrees(): bool
80
-    {
81
-        return isset($this->_excluded);
82
-    }
74
+	/**
75
+	 * Whether excluded subtrees are present.
76
+	 *
77
+	 * @return bool
78
+	 */
79
+	public function hasExcludedSubtrees(): bool
80
+	{
81
+		return isset($this->_excluded);
82
+	}
83 83
 
84
-    /**
85
-     * Get excluded subtrees.
86
-     *
87
-     * @throws \LogicException If not set
88
-     *
89
-     * @return GeneralSubtrees
90
-     */
91
-    public function excludedSubtrees(): GeneralSubtrees
92
-    {
93
-        if (!$this->hasExcludedSubtrees()) {
94
-            throw new \LogicException('No excluded subtrees.');
95
-        }
96
-        return $this->_excluded;
97
-    }
84
+	/**
85
+	 * Get excluded subtrees.
86
+	 *
87
+	 * @throws \LogicException If not set
88
+	 *
89
+	 * @return GeneralSubtrees
90
+	 */
91
+	public function excludedSubtrees(): GeneralSubtrees
92
+	{
93
+		if (!$this->hasExcludedSubtrees()) {
94
+			throw new \LogicException('No excluded subtrees.');
95
+		}
96
+		return $this->_excluded;
97
+	}
98 98
 
99
-    /**
100
-     * {@inheritdoc}
101
-     */
102
-    protected static function _fromDER(string $data, bool $critical): Extension
103
-    {
104
-        $seq = UnspecifiedType::fromDER($data)->asSequence();
105
-        $permitted = null;
106
-        $excluded = null;
107
-        if ($seq->hasTagged(0)) {
108
-            $permitted = GeneralSubtrees::fromASN1(
109
-                $seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
110
-        }
111
-        if ($seq->hasTagged(1)) {
112
-            $excluded = GeneralSubtrees::fromASN1(
113
-                $seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
114
-        }
115
-        return new self($critical, $permitted, $excluded);
116
-    }
99
+	/**
100
+	 * {@inheritdoc}
101
+	 */
102
+	protected static function _fromDER(string $data, bool $critical): Extension
103
+	{
104
+		$seq = UnspecifiedType::fromDER($data)->asSequence();
105
+		$permitted = null;
106
+		$excluded = null;
107
+		if ($seq->hasTagged(0)) {
108
+			$permitted = GeneralSubtrees::fromASN1(
109
+				$seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
110
+		}
111
+		if ($seq->hasTagged(1)) {
112
+			$excluded = GeneralSubtrees::fromASN1(
113
+				$seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)->asSequence());
114
+		}
115
+		return new self($critical, $permitted, $excluded);
116
+	}
117 117
 
118
-    /**
119
-     * {@inheritdoc}
120
-     */
121
-    protected function _valueASN1(): Element
122
-    {
123
-        $elements = [];
124
-        if (isset($this->_permitted)) {
125
-            $elements[] = new ImplicitlyTaggedType(0, $this->_permitted->toASN1());
126
-        }
127
-        if (isset($this->_excluded)) {
128
-            $elements[] = new ImplicitlyTaggedType(1, $this->_excluded->toASN1());
129
-        }
130
-        return new Sequence(...$elements);
131
-    }
118
+	/**
119
+	 * {@inheritdoc}
120
+	 */
121
+	protected function _valueASN1(): Element
122
+	{
123
+		$elements = [];
124
+		if (isset($this->_permitted)) {
125
+			$elements[] = new ImplicitlyTaggedType(0, $this->_permitted->toASN1());
126
+		}
127
+		if (isset($this->_excluded)) {
128
+			$elements[] = new ImplicitlyTaggedType(1, $this->_excluded->toASN1());
129
+		}
130
+		return new Sequence(...$elements);
131
+	}
132 132
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension;
6 6
 
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/Target/TargetName.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -16,57 +16,57 @@
 block discarded – undo
16 16
  */
17 17
 class TargetName extends Target
18 18
 {
19
-    /**
20
-     * Name.
21
-     *
22
-     * @var GeneralName
23
-     */
24
-    protected $_name;
19
+	/**
20
+	 * Name.
21
+	 *
22
+	 * @var GeneralName
23
+	 */
24
+	protected $_name;
25 25
 
26
-    /**
27
-     * Constructor.
28
-     *
29
-     * @param GeneralName $name
30
-     */
31
-    public function __construct(GeneralName $name)
32
-    {
33
-        $this->_name = $name;
34
-        $this->_type = self::TYPE_NAME;
35
-    }
26
+	/**
27
+	 * Constructor.
28
+	 *
29
+	 * @param GeneralName $name
30
+	 */
31
+	public function __construct(GeneralName $name)
32
+	{
33
+		$this->_name = $name;
34
+		$this->_type = self::TYPE_NAME;
35
+	}
36 36
 
37
-    /**
38
-     * {@inheritdoc}
39
-     *
40
-     * @return self
41
-     */
42
-    public static function fromChosenASN1(TaggedType $el): Target
43
-    {
44
-        return new self(GeneralName::fromASN1($el));
45
-    }
37
+	/**
38
+	 * {@inheritdoc}
39
+	 *
40
+	 * @return self
41
+	 */
42
+	public static function fromChosenASN1(TaggedType $el): Target
43
+	{
44
+		return new self(GeneralName::fromASN1($el));
45
+	}
46 46
 
47
-    /**
48
-     * {@inheritdoc}
49
-     */
50
-    public function string(): string
51
-    {
52
-        return $this->_name->string();
53
-    }
47
+	/**
48
+	 * {@inheritdoc}
49
+	 */
50
+	public function string(): string
51
+	{
52
+		return $this->_name->string();
53
+	}
54 54
 
55
-    /**
56
-     * Get name.
57
-     *
58
-     * @return GeneralName
59
-     */
60
-    public function name(): GeneralName
61
-    {
62
-        return $this->_name;
63
-    }
55
+	/**
56
+	 * Get name.
57
+	 *
58
+	 * @return GeneralName
59
+	 */
60
+	public function name(): GeneralName
61
+	{
62
+		return $this->_name;
63
+	}
64 64
 
65
-    /**
66
-     * {@inheritdoc}
67
-     */
68
-    public function toASN1(): Element
69
-    {
70
-        return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1());
71
-    }
65
+	/**
66
+	 * {@inheritdoc}
67
+	 */
68
+	public function toASN1(): Element
69
+	{
70
+		return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1());
71
+	}
72 72
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension\Target;
6 6
 
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/Target/TargetGroup.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -16,57 +16,57 @@
 block discarded – undo
16 16
  */
17 17
 class TargetGroup extends Target
18 18
 {
19
-    /**
20
-     * Group name.
21
-     *
22
-     * @var GeneralName
23
-     */
24
-    protected $_name;
19
+	/**
20
+	 * Group name.
21
+	 *
22
+	 * @var GeneralName
23
+	 */
24
+	protected $_name;
25 25
 
26
-    /**
27
-     * Constructor.
28
-     *
29
-     * @param GeneralName $name
30
-     */
31
-    public function __construct(GeneralName $name)
32
-    {
33
-        $this->_name = $name;
34
-        $this->_type = self::TYPE_GROUP;
35
-    }
26
+	/**
27
+	 * Constructor.
28
+	 *
29
+	 * @param GeneralName $name
30
+	 */
31
+	public function __construct(GeneralName $name)
32
+	{
33
+		$this->_name = $name;
34
+		$this->_type = self::TYPE_GROUP;
35
+	}
36 36
 
37
-    /**
38
-     * {@inheritdoc}
39
-     *
40
-     * @return self
41
-     */
42
-    public static function fromChosenASN1(TaggedType $el): Target
43
-    {
44
-        return new self(GeneralName::fromASN1($el));
45
-    }
37
+	/**
38
+	 * {@inheritdoc}
39
+	 *
40
+	 * @return self
41
+	 */
42
+	public static function fromChosenASN1(TaggedType $el): Target
43
+	{
44
+		return new self(GeneralName::fromASN1($el));
45
+	}
46 46
 
47
-    /**
48
-     * {@inheritdoc}
49
-     */
50
-    public function string(): string
51
-    {
52
-        return $this->_name->string();
53
-    }
47
+	/**
48
+	 * {@inheritdoc}
49
+	 */
50
+	public function string(): string
51
+	{
52
+		return $this->_name->string();
53
+	}
54 54
 
55
-    /**
56
-     * Get group name.
57
-     *
58
-     * @return GeneralName
59
-     */
60
-    public function name(): GeneralName
61
-    {
62
-        return $this->_name;
63
-    }
55
+	/**
56
+	 * Get group name.
57
+	 *
58
+	 * @return GeneralName
59
+	 */
60
+	public function name(): GeneralName
61
+	{
62
+		return $this->_name;
63
+	}
64 64
 
65
-    /**
66
-     * {@inheritdoc}
67
-     */
68
-    public function toASN1(): Element
69
-    {
70
-        return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1());
71
-    }
65
+	/**
66
+	 * {@inheritdoc}
67
+	 */
68
+	public function toASN1(): Element
69
+	{
70
+		return new ExplicitlyTaggedType($this->_type, $this->_name->toASN1());
71
+	}
72 72
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension\Target;
6 6
 
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/Target/Targets.php 2 patches
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -14,135 +14,135 @@
 block discarded – undo
14 14
  */
15 15
 class Targets implements \Countable, \IteratorAggregate
16 16
 {
17
-    /**
18
-     * Target elements.
19
-     *
20
-     * @var Target[]
21
-     */
22
-    protected $_targets;
17
+	/**
18
+	 * Target elements.
19
+	 *
20
+	 * @var Target[]
21
+	 */
22
+	protected $_targets;
23 23
 
24
-    /**
25
-     * Constructor.
26
-     *
27
-     * @param Target ...$targets
28
-     */
29
-    public function __construct(Target ...$targets)
30
-    {
31
-        $this->_targets = $targets;
32
-    }
24
+	/**
25
+	 * Constructor.
26
+	 *
27
+	 * @param Target ...$targets
28
+	 */
29
+	public function __construct(Target ...$targets)
30
+	{
31
+		$this->_targets = $targets;
32
+	}
33 33
 
34
-    /**
35
-     * Initialize from ASN.1.
36
-     *
37
-     * @param Sequence $seq
38
-     *
39
-     * @return self
40
-     */
41
-    public static function fromASN1(Sequence $seq): self
42
-    {
43
-        $targets = array_map(
44
-            function (UnspecifiedType $el) {
45
-                return Target::fromASN1($el->asTagged());
46
-            }, $seq->elements());
47
-        return new self(...$targets);
48
-    }
34
+	/**
35
+	 * Initialize from ASN.1.
36
+	 *
37
+	 * @param Sequence $seq
38
+	 *
39
+	 * @return self
40
+	 */
41
+	public static function fromASN1(Sequence $seq): self
42
+	{
43
+		$targets = array_map(
44
+			function (UnspecifiedType $el) {
45
+				return Target::fromASN1($el->asTagged());
46
+			}, $seq->elements());
47
+		return new self(...$targets);
48
+	}
49 49
 
50
-    /**
51
-     * Get all targets.
52
-     *
53
-     * @return Target[]
54
-     */
55
-    public function all(): array
56
-    {
57
-        return $this->_targets;
58
-    }
50
+	/**
51
+	 * Get all targets.
52
+	 *
53
+	 * @return Target[]
54
+	 */
55
+	public function all(): array
56
+	{
57
+		return $this->_targets;
58
+	}
59 59
 
60
-    /**
61
-     * Get all name targets.
62
-     *
63
-     * @return Target[]
64
-     */
65
-    public function nameTargets(): array
66
-    {
67
-        return $this->_allOfType(Target::TYPE_NAME);
68
-    }
60
+	/**
61
+	 * Get all name targets.
62
+	 *
63
+	 * @return Target[]
64
+	 */
65
+	public function nameTargets(): array
66
+	{
67
+		return $this->_allOfType(Target::TYPE_NAME);
68
+	}
69 69
 
70
-    /**
71
-     * Get all group targets.
72
-     *
73
-     * @return Target[]
74
-     */
75
-    public function groupTargets(): array
76
-    {
77
-        return $this->_allOfType(Target::TYPE_GROUP);
78
-    }
70
+	/**
71
+	 * Get all group targets.
72
+	 *
73
+	 * @return Target[]
74
+	 */
75
+	public function groupTargets(): array
76
+	{
77
+		return $this->_allOfType(Target::TYPE_GROUP);
78
+	}
79 79
 
80
-    /**
81
-     * Check whether given target is present.
82
-     *
83
-     * @param Target $target
84
-     *
85
-     * @return bool
86
-     */
87
-    public function hasTarget(Target $target): bool
88
-    {
89
-        foreach ($this->_allOfType($target->type()) as $t) {
90
-            if ($target->equals($t)) {
91
-                return true;
92
-            }
93
-        }
94
-        return false;
95
-    }
80
+	/**
81
+	 * Check whether given target is present.
82
+	 *
83
+	 * @param Target $target
84
+	 *
85
+	 * @return bool
86
+	 */
87
+	public function hasTarget(Target $target): bool
88
+	{
89
+		foreach ($this->_allOfType($target->type()) as $t) {
90
+			if ($target->equals($t)) {
91
+				return true;
92
+			}
93
+		}
94
+		return false;
95
+	}
96 96
 
97
-    /**
98
-     * Generate ASN.1 structure.
99
-     *
100
-     * @return Sequence
101
-     */
102
-    public function toASN1(): Sequence
103
-    {
104
-        $elements = array_map(
105
-            function (Target $target) {
106
-                return $target->toASN1();
107
-            }, $this->_targets);
108
-        return new Sequence(...$elements);
109
-    }
97
+	/**
98
+	 * Generate ASN.1 structure.
99
+	 *
100
+	 * @return Sequence
101
+	 */
102
+	public function toASN1(): Sequence
103
+	{
104
+		$elements = array_map(
105
+			function (Target $target) {
106
+				return $target->toASN1();
107
+			}, $this->_targets);
108
+		return new Sequence(...$elements);
109
+	}
110 110
 
111
-    /**
112
-     * @see \Countable::count()
113
-     *
114
-     * @return int
115
-     */
116
-    public function count(): int
117
-    {
118
-        return count($this->_targets);
119
-    }
111
+	/**
112
+	 * @see \Countable::count()
113
+	 *
114
+	 * @return int
115
+	 */
116
+	public function count(): int
117
+	{
118
+		return count($this->_targets);
119
+	}
120 120
 
121
-    /**
122
-     * Get iterator for targets.
123
-     *
124
-     * @see \IteratorAggregate::getIterator()
125
-     *
126
-     * @return \ArrayIterator
127
-     */
128
-    public function getIterator(): \ArrayIterator
129
-    {
130
-        return new \ArrayIterator($this->_targets);
131
-    }
121
+	/**
122
+	 * Get iterator for targets.
123
+	 *
124
+	 * @see \IteratorAggregate::getIterator()
125
+	 *
126
+	 * @return \ArrayIterator
127
+	 */
128
+	public function getIterator(): \ArrayIterator
129
+	{
130
+		return new \ArrayIterator($this->_targets);
131
+	}
132 132
 
133
-    /**
134
-     * Get all targets of given type.
135
-     *
136
-     * @param int $type
137
-     *
138
-     * @return Target[]
139
-     */
140
-    protected function _allOfType(int $type): array
141
-    {
142
-        return array_values(
143
-            array_filter($this->_targets,
144
-                function (Target $target) use ($type) {
145
-                    return $target->type() == $type;
146
-                }));
147
-    }
133
+	/**
134
+	 * Get all targets of given type.
135
+	 *
136
+	 * @param int $type
137
+	 *
138
+	 * @return Target[]
139
+	 */
140
+	protected function _allOfType(int $type): array
141
+	{
142
+		return array_values(
143
+			array_filter($this->_targets,
144
+				function (Target $target) use ($type) {
145
+					return $target->type() == $type;
146
+				}));
147
+	}
148 148
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension\Target;
6 6
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public static function fromASN1(Sequence $seq): self
42 42
     {
43 43
         $targets = array_map(
44
-            function (UnspecifiedType $el) {
44
+            function(UnspecifiedType $el) {
45 45
                 return Target::fromASN1($el->asTagged());
46 46
             }, $seq->elements());
47 47
         return new self(...$targets);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     public function toASN1(): Sequence
103 103
     {
104 104
         $elements = array_map(
105
-            function (Target $target) {
105
+            function(Target $target) {
106 106
                 return $target->toASN1();
107 107
             }, $this->_targets);
108 108
         return new Sequence(...$elements);
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     {
142 142
         return array_values(
143 143
             array_filter($this->_targets,
144
-                function (Target $target) use ($type) {
144
+                function(Target $target) use ($type) {
145 145
                     return $target->type() == $type;
146 146
                 }));
147 147
     }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/Target/Target.php 3 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -14,92 +14,92 @@
 block discarded – undo
14 14
  */
15 15
 abstract class Target
16 16
 {
17
-    const TYPE_NAME = 0;
18
-    const TYPE_GROUP = 1;
19
-    const TYPE_CERT = 2;
17
+	const TYPE_NAME = 0;
18
+	const TYPE_GROUP = 1;
19
+	const TYPE_CERT = 2;
20 20
 
21
-    /**
22
-     * Type tag.
23
-     *
24
-     * @var int
25
-     */
26
-    protected $_type;
21
+	/**
22
+	 * Type tag.
23
+	 *
24
+	 * @var int
25
+	 */
26
+	protected $_type;
27 27
 
28
-    /**
29
-     * Generate ASN.1 element.
30
-     *
31
-     * @return Element
32
-     */
33
-    abstract public function toASN1(): Element;
28
+	/**
29
+	 * Generate ASN.1 element.
30
+	 *
31
+	 * @return Element
32
+	 */
33
+	abstract public function toASN1(): Element;
34 34
 
35
-    /**
36
-     * Get string value of the target.
37
-     *
38
-     * @return string
39
-     */
40
-    abstract public function string(): string;
35
+	/**
36
+	 * Get string value of the target.
37
+	 *
38
+	 * @return string
39
+	 */
40
+	abstract public function string(): string;
41 41
 
42
-    /**
43
-     * Initialize concrete object from the chosen ASN.1 element.
44
-     *
45
-     * @param TaggedType $el
46
-     *
47
-     * @return self
48
-     */
49
-    public static function fromChosenASN1(TaggedType $el): Target
50
-    {
51
-        throw new \BadMethodCallException(
52
-            __FUNCTION__ . ' must be implemented in the derived class.');
53
-    }
42
+	/**
43
+	 * Initialize concrete object from the chosen ASN.1 element.
44
+	 *
45
+	 * @param TaggedType $el
46
+	 *
47
+	 * @return self
48
+	 */
49
+	public static function fromChosenASN1(TaggedType $el): Target
50
+	{
51
+		throw new \BadMethodCallException(
52
+			__FUNCTION__ . ' must be implemented in the derived class.');
53
+	}
54 54
 
55
-    /**
56
-     * Parse from ASN.1.
57
-     *
58
-     * @param TaggedType $el
59
-     *
60
-     * @throws \UnexpectedValueException
61
-     *
62
-     * @return self
63
-     */
64
-    public static function fromASN1(TaggedType $el): self
65
-    {
66
-        switch ($el->tag()) {
67
-            case self::TYPE_NAME:
68
-                return TargetName::fromChosenASN1($el->asExplicit()->asTagged());
69
-            case self::TYPE_GROUP:
70
-                return TargetGroup::fromChosenASN1($el->asExplicit()->asTagged());
71
-            case self::TYPE_CERT:
72
-                throw new \RuntimeException('targetCert not supported.');
73
-        }
74
-        throw new \UnexpectedValueException(
75
-            'Target type ' . $el->tag() . ' not supported.');
76
-    }
55
+	/**
56
+	 * Parse from ASN.1.
57
+	 *
58
+	 * @param TaggedType $el
59
+	 *
60
+	 * @throws \UnexpectedValueException
61
+	 *
62
+	 * @return self
63
+	 */
64
+	public static function fromASN1(TaggedType $el): self
65
+	{
66
+		switch ($el->tag()) {
67
+			case self::TYPE_NAME:
68
+				return TargetName::fromChosenASN1($el->asExplicit()->asTagged());
69
+			case self::TYPE_GROUP:
70
+				return TargetGroup::fromChosenASN1($el->asExplicit()->asTagged());
71
+			case self::TYPE_CERT:
72
+				throw new \RuntimeException('targetCert not supported.');
73
+		}
74
+		throw new \UnexpectedValueException(
75
+			'Target type ' . $el->tag() . ' not supported.');
76
+	}
77 77
 
78
-    /**
79
-     * Get type tag.
80
-     *
81
-     * @return int
82
-     */
83
-    public function type(): int
84
-    {
85
-        return $this->_type;
86
-    }
78
+	/**
79
+	 * Get type tag.
80
+	 *
81
+	 * @return int
82
+	 */
83
+	public function type(): int
84
+	{
85
+		return $this->_type;
86
+	}
87 87
 
88
-    /**
89
-     * Check whether target is equal to another.
90
-     *
91
-     * @param Target $other
92
-     *
93
-     * @return bool
94
-     */
95
-    public function equals(Target $other): bool
96
-    {
97
-        if ($this->_type !== $other->_type) {
98
-            return false;
99
-        }
100
-        if ($this->toASN1()->toDER() !== $other->toASN1()->toDER()) {
101
-            return false;
102
-        }
103
-        return true;
104
-    }
88
+	/**
89
+	 * Check whether target is equal to another.
90
+	 *
91
+	 * @param Target $other
92
+	 *
93
+	 * @return bool
94
+	 */
95
+	public function equals(Target $other): bool
96
+	{
97
+		if ($this->_type !== $other->_type) {
98
+			return false;
99
+		}
100
+		if ($this->toASN1()->toDER() !== $other->toASN1()->toDER()) {
101
+			return false;
102
+		}
103
+		return true;
104
+	}
105 105
 }
Please login to merge, or discard this patch.
Switch Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -64,12 +64,12 @@
 block discarded – undo
64 64
     public static function fromASN1(TaggedType $el): self
65 65
     {
66 66
         switch ($el->tag()) {
67
-            case self::TYPE_NAME:
68
-                return TargetName::fromChosenASN1($el->asExplicit()->asTagged());
69
-            case self::TYPE_GROUP:
70
-                return TargetGroup::fromChosenASN1($el->asExplicit()->asTagged());
71
-            case self::TYPE_CERT:
72
-                throw new \RuntimeException('targetCert not supported.');
67
+        case self::TYPE_NAME:
68
+            return TargetName::fromChosenASN1($el->asExplicit()->asTagged());
69
+        case self::TYPE_GROUP:
70
+            return TargetGroup::fromChosenASN1($el->asExplicit()->asTagged());
71
+        case self::TYPE_CERT:
72
+            throw new \RuntimeException('targetCert not supported.');
73 73
         }
74 74
         throw new \UnexpectedValueException(
75 75
             'Target type ' . $el->tag() . ' not supported.');
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension\Target;
6 6
 
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/TargetInformationExtension.php 2 patches
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -21,134 +21,134 @@
 block discarded – undo
21 21
  */
22 22
 class TargetInformationExtension extends Extension implements \Countable, \IteratorAggregate
23 23
 {
24
-    /**
25
-     * Targets elements.
26
-     *
27
-     * @var Targets[]
28
-     */
29
-    protected $_targets;
24
+	/**
25
+	 * Targets elements.
26
+	 *
27
+	 * @var Targets[]
28
+	 */
29
+	protected $_targets;
30 30
 
31
-    /**
32
-     * Targets[] merged to single Targets.
33
-     *
34
-     * @var null|Targets
35
-     */
36
-    private $_merged;
31
+	/**
32
+	 * Targets[] merged to single Targets.
33
+	 *
34
+	 * @var null|Targets
35
+	 */
36
+	private $_merged;
37 37
 
38
-    /**
39
-     * Constructor.
40
-     *
41
-     * @param bool    $critical
42
-     * @param Targets ...$targets
43
-     */
44
-    public function __construct(bool $critical, Targets ...$targets)
45
-    {
46
-        parent::__construct(self::OID_TARGET_INFORMATION, $critical);
47
-        $this->_targets = $targets;
48
-    }
38
+	/**
39
+	 * Constructor.
40
+	 *
41
+	 * @param bool    $critical
42
+	 * @param Targets ...$targets
43
+	 */
44
+	public function __construct(bool $critical, Targets ...$targets)
45
+	{
46
+		parent::__construct(self::OID_TARGET_INFORMATION, $critical);
47
+		$this->_targets = $targets;
48
+	}
49 49
 
50
-    /**
51
-     * Reset internal state on clone.
52
-     */
53
-    public function __clone()
54
-    {
55
-        $this->_merged = null;
56
-    }
50
+	/**
51
+	 * Reset internal state on clone.
52
+	 */
53
+	public function __clone()
54
+	{
55
+		$this->_merged = null;
56
+	}
57 57
 
58
-    /**
59
-     * Initialize from one or more Target objects.
60
-     *
61
-     * Extension criticality shall be set to true as specified by RFC 5755.
62
-     *
63
-     * @param Target ...$target
64
-     *
65
-     * @return TargetInformationExtension
66
-     */
67
-    public static function fromTargets(Target ...$target): self
68
-    {
69
-        return new self(true, new Targets(...$target));
70
-    }
58
+	/**
59
+	 * Initialize from one or more Target objects.
60
+	 *
61
+	 * Extension criticality shall be set to true as specified by RFC 5755.
62
+	 *
63
+	 * @param Target ...$target
64
+	 *
65
+	 * @return TargetInformationExtension
66
+	 */
67
+	public static function fromTargets(Target ...$target): self
68
+	{
69
+		return new self(true, new Targets(...$target));
70
+	}
71 71
 
72
-    /**
73
-     * Get all targets.
74
-     *
75
-     * @return Targets
76
-     */
77
-    public function targets(): Targets
78
-    {
79
-        if (!isset($this->_merged)) {
80
-            $a = [];
81
-            foreach ($this->_targets as $targets) {
82
-                $a = array_merge($a, $targets->all());
83
-            }
84
-            $this->_merged = new Targets(...$a);
85
-        }
86
-        return $this->_merged;
87
-    }
72
+	/**
73
+	 * Get all targets.
74
+	 *
75
+	 * @return Targets
76
+	 */
77
+	public function targets(): Targets
78
+	{
79
+		if (!isset($this->_merged)) {
80
+			$a = [];
81
+			foreach ($this->_targets as $targets) {
82
+				$a = array_merge($a, $targets->all());
83
+			}
84
+			$this->_merged = new Targets(...$a);
85
+		}
86
+		return $this->_merged;
87
+	}
88 88
 
89
-    /**
90
-     * Get all name targets.
91
-     *
92
-     * @return Target[]
93
-     */
94
-    public function names(): array
95
-    {
96
-        return $this->targets()->nameTargets();
97
-    }
89
+	/**
90
+	 * Get all name targets.
91
+	 *
92
+	 * @return Target[]
93
+	 */
94
+	public function names(): array
95
+	{
96
+		return $this->targets()->nameTargets();
97
+	}
98 98
 
99
-    /**
100
-     * Get all group targets.
101
-     *
102
-     * @return Target[]
103
-     */
104
-    public function groups(): array
105
-    {
106
-        return $this->targets()->groupTargets();
107
-    }
99
+	/**
100
+	 * Get all group targets.
101
+	 *
102
+	 * @return Target[]
103
+	 */
104
+	public function groups(): array
105
+	{
106
+		return $this->targets()->groupTargets();
107
+	}
108 108
 
109
-    /**
110
-     * @see \Countable::count()
111
-     *
112
-     * @return int
113
-     */
114
-    public function count(): int
115
-    {
116
-        return count($this->targets());
117
-    }
109
+	/**
110
+	 * @see \Countable::count()
111
+	 *
112
+	 * @return int
113
+	 */
114
+	public function count(): int
115
+	{
116
+		return count($this->targets());
117
+	}
118 118
 
119
-    /**
120
-     * Get iterator for targets.
121
-     *
122
-     * @see \IteratorAggregate::getIterator()
123
-     *
124
-     * @return \ArrayIterator
125
-     */
126
-    public function getIterator(): \ArrayIterator
127
-    {
128
-        return new \ArrayIterator($this->targets()->all());
129
-    }
119
+	/**
120
+	 * Get iterator for targets.
121
+	 *
122
+	 * @see \IteratorAggregate::getIterator()
123
+	 *
124
+	 * @return \ArrayIterator
125
+	 */
126
+	public function getIterator(): \ArrayIterator
127
+	{
128
+		return new \ArrayIterator($this->targets()->all());
129
+	}
130 130
 
131
-    /**
132
-     * {@inheritdoc}
133
-     */
134
-    protected static function _fromDER(string $data, bool $critical): Extension
135
-    {
136
-        $targets = array_map(
137
-            function (UnspecifiedType $el) {
138
-                return Targets::fromASN1($el->asSequence());
139
-            }, UnspecifiedType::fromDER($data)->asSequence()->elements());
140
-        return new self($critical, ...$targets);
141
-    }
131
+	/**
132
+	 * {@inheritdoc}
133
+	 */
134
+	protected static function _fromDER(string $data, bool $critical): Extension
135
+	{
136
+		$targets = array_map(
137
+			function (UnspecifiedType $el) {
138
+				return Targets::fromASN1($el->asSequence());
139
+			}, UnspecifiedType::fromDER($data)->asSequence()->elements());
140
+		return new self($critical, ...$targets);
141
+	}
142 142
 
143
-    /**
144
-     * {@inheritdoc}
145
-     */
146
-    protected function _valueASN1(): Element
147
-    {
148
-        $elements = array_map(
149
-            function (Targets $targets) {
150
-                return $targets->toASN1();
151
-            }, $this->_targets);
152
-        return new Sequence(...$elements);
153
-    }
143
+	/**
144
+	 * {@inheritdoc}
145
+	 */
146
+	protected function _valueASN1(): Element
147
+	{
148
+		$elements = array_map(
149
+			function (Targets $targets) {
150
+				return $targets->toASN1();
151
+			}, $this->_targets);
152
+		return new Sequence(...$elements);
153
+	}
154 154
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension;
6 6
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     protected static function _fromDER(string $data, bool $critical): Extension
135 135
     {
136 136
         $targets = array_map(
137
-            function (UnspecifiedType $el) {
137
+            function(UnspecifiedType $el) {
138 138
                 return Targets::fromASN1($el->asSequence());
139 139
             }, UnspecifiedType::fromDER($data)->asSequence()->elements());
140 140
         return new self($critical, ...$targets);
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     protected function _valueASN1(): Element
147 147
     {
148 148
         $elements = array_map(
149
-            function (Targets $targets) {
149
+            function(Targets $targets) {
150 150
                 return $targets->toASN1();
151 151
             }, $this->_targets);
152 152
         return new Sequence(...$elements);
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/IssuerAlternativeNameExtension.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -15,50 +15,50 @@
 block discarded – undo
15 15
  */
16 16
 class IssuerAlternativeNameExtension extends Extension
17 17
 {
18
-    /**
19
-     * Names.
20
-     *
21
-     * @var GeneralNames
22
-     */
23
-    protected $_names;
18
+	/**
19
+	 * Names.
20
+	 *
21
+	 * @var GeneralNames
22
+	 */
23
+	protected $_names;
24 24
 
25
-    /**
26
-     * Constructor.
27
-     *
28
-     * @param bool         $critical
29
-     * @param GeneralNames $names
30
-     */
31
-    public function __construct(bool $critical, GeneralNames $names)
32
-    {
33
-        parent::__construct(self::OID_ISSUER_ALT_NAME, $critical);
34
-        $this->_names = $names;
35
-    }
25
+	/**
26
+	 * Constructor.
27
+	 *
28
+	 * @param bool         $critical
29
+	 * @param GeneralNames $names
30
+	 */
31
+	public function __construct(bool $critical, GeneralNames $names)
32
+	{
33
+		parent::__construct(self::OID_ISSUER_ALT_NAME, $critical);
34
+		$this->_names = $names;
35
+	}
36 36
 
37
-    /**
38
-     * Get names.
39
-     *
40
-     * @return GeneralNames
41
-     */
42
-    public function names(): GeneralNames
43
-    {
44
-        return $this->_names;
45
-    }
37
+	/**
38
+	 * Get names.
39
+	 *
40
+	 * @return GeneralNames
41
+	 */
42
+	public function names(): GeneralNames
43
+	{
44
+		return $this->_names;
45
+	}
46 46
 
47
-    /**
48
-     * {@inheritdoc}
49
-     */
50
-    protected static function _fromDER(string $data, bool $critical): Extension
51
-    {
52
-        return new self($critical,
53
-            GeneralNames::fromASN1(
54
-                UnspecifiedType::fromDER($data)->asSequence()));
55
-    }
47
+	/**
48
+	 * {@inheritdoc}
49
+	 */
50
+	protected static function _fromDER(string $data, bool $critical): Extension
51
+	{
52
+		return new self($critical,
53
+			GeneralNames::fromASN1(
54
+				UnspecifiedType::fromDER($data)->asSequence()));
55
+	}
56 56
 
57
-    /**
58
-     * {@inheritdoc}
59
-     */
60
-    protected function _valueASN1(): Element
61
-    {
62
-        return $this->_names->toASN1();
63
-    }
57
+	/**
58
+	 * {@inheritdoc}
59
+	 */
60
+	protected function _valueASN1(): Element
61
+	{
62
+		return $this->_names->toASN1();
63
+	}
64 64
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension;
6 6
 
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/AAControlsExtension.php 2 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -19,207 +19,207 @@
 block discarded – undo
19 19
  */
20 20
 class AAControlsExtension extends Extension
21 21
 {
22
-    /**
23
-     * Path length contraint.
24
-     *
25
-     * @var null|int
26
-     */
27
-    protected $_pathLenConstraint;
28
-
29
-    /**
30
-     * Permitted attributes.
31
-     *
32
-     * Array of OID's.
33
-     *
34
-     * @var null|string[]
35
-     */
36
-    protected $_permittedAttrs;
37
-
38
-    /**
39
-     * Excluded attributes.
40
-     *
41
-     * Array of OID's.
42
-     *
43
-     * @var null|string[]
44
-     */
45
-    protected $_excludedAttrs;
46
-
47
-    /**
48
-     * Whether to permit unspecified attributes.
49
-     *
50
-     * @var bool
51
-     */
52
-    protected $_permitUnSpecified;
53
-
54
-    /**
55
-     * Constructor.
56
-     *
57
-     * @param bool          $critical
58
-     * @param null|int      $path_len
59
-     * @param null|string[] $permitted
60
-     * @param null|string[] $excluded
61
-     * @param bool          $permit_unspecified
62
-     */
63
-    public function __construct(bool $critical, ?int $path_len = null,
64
-        ?array $permitted = null, ?array $excluded = null, bool $permit_unspecified = true)
65
-    {
66
-        parent::__construct(self::OID_AA_CONTROLS, $critical);
67
-        $this->_pathLenConstraint = $path_len;
68
-        $this->_permittedAttrs = $permitted;
69
-        $this->_excludedAttrs = $excluded;
70
-        $this->_permitUnSpecified = $permit_unspecified;
71
-    }
72
-
73
-    /**
74
-     * Check whether path length constraint is present.
75
-     *
76
-     * @return bool
77
-     */
78
-    public function hasPathLen(): bool
79
-    {
80
-        return isset($this->_pathLenConstraint);
81
-    }
82
-
83
-    /**
84
-     * Get path length constraint.
85
-     *
86
-     * @throws \LogicException If not set
87
-     *
88
-     * @return int
89
-     */
90
-    public function pathLen(): int
91
-    {
92
-        if (!$this->hasPathLen()) {
93
-            throw new \LogicException('pathLen not set.');
94
-        }
95
-        return $this->_pathLenConstraint;
96
-    }
97
-
98
-    /**
99
-     * Check whether permitted attributes are present.
100
-     *
101
-     * @return bool
102
-     */
103
-    public function hasPermittedAttrs(): bool
104
-    {
105
-        return isset($this->_permittedAttrs);
106
-    }
107
-
108
-    /**
109
-     * Get OID's of permitted attributes.
110
-     *
111
-     * @throws \LogicException If not set
112
-     *
113
-     * @return string[]
114
-     */
115
-    public function permittedAttrs(): array
116
-    {
117
-        if (!$this->hasPermittedAttrs()) {
118
-            throw new \LogicException('permittedAttrs not set.');
119
-        }
120
-        return $this->_permittedAttrs;
121
-    }
122
-
123
-    /**
124
-     * Check whether excluded attributes are present.
125
-     *
126
-     * @return bool
127
-     */
128
-    public function hasExcludedAttrs(): bool
129
-    {
130
-        return isset($this->_excludedAttrs);
131
-    }
132
-
133
-    /**
134
-     * Get OID's of excluded attributes.
135
-     *
136
-     * @throws \LogicException If not set
137
-     *
138
-     * @return string[]
139
-     */
140
-    public function excludedAttrs(): array
141
-    {
142
-        if (!$this->hasExcludedAttrs()) {
143
-            throw new \LogicException('excludedAttrs not set.');
144
-        }
145
-        return $this->_excludedAttrs;
146
-    }
147
-
148
-    /**
149
-     * Whether to permit attributes that are not explicitly specified in
150
-     * neither permitted nor excluded list.
151
-     *
152
-     * @return bool
153
-     */
154
-    public function permitUnspecified(): bool
155
-    {
156
-        return $this->_permitUnSpecified;
157
-    }
158
-
159
-    /**
160
-     * {@inheritdoc}
161
-     */
162
-    protected static function _fromDER(string $data, bool $critical): Extension
163
-    {
164
-        $seq = UnspecifiedType::fromDER($data)->asSequence();
165
-        $path_len = null;
166
-        $permitted = null;
167
-        $excluded = null;
168
-        $permit_unspecified = true;
169
-        $idx = 0;
170
-        if ($seq->has($idx, Element::TYPE_INTEGER)) {
171
-            $path_len = $seq->at($idx++)->asInteger()->intNumber();
172
-        }
173
-        if ($seq->hasTagged(0)) {
174
-            $attr_seq = $seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)
175
-                ->asSequence();
176
-            $permitted = array_map(
177
-                function (UnspecifiedType $el) {
178
-                    return $el->asObjectIdentifier()->oid();
179
-                }, $attr_seq->elements());
180
-            ++$idx;
181
-        }
182
-        if ($seq->hasTagged(1)) {
183
-            $attr_seq = $seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)
184
-                ->asSequence();
185
-            $excluded = array_map(
186
-                function (UnspecifiedType $el) {
187
-                    return $el->asObjectIdentifier()->oid();
188
-                }, $attr_seq->elements());
189
-            ++$idx;
190
-        }
191
-        if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
192
-            $permit_unspecified = $seq->at($idx++)->asBoolean()->value();
193
-        }
194
-        return new self($critical, $path_len, $permitted, $excluded, $permit_unspecified);
195
-    }
196
-
197
-    /**
198
-     * {@inheritdoc}
199
-     */
200
-    protected function _valueASN1(): Element
201
-    {
202
-        $elements = [];
203
-        if (isset($this->_pathLenConstraint)) {
204
-            $elements[] = new Integer($this->_pathLenConstraint);
205
-        }
206
-        if (isset($this->_permittedAttrs)) {
207
-            $oids = array_map(
208
-                function ($oid) {
209
-                    return new ObjectIdentifier($oid);
210
-                }, $this->_permittedAttrs);
211
-            $elements[] = new ImplicitlyTaggedType(0, new Sequence(...$oids));
212
-        }
213
-        if (isset($this->_excludedAttrs)) {
214
-            $oids = array_map(
215
-                function ($oid) {
216
-                    return new ObjectIdentifier($oid);
217
-                }, $this->_excludedAttrs);
218
-            $elements[] = new ImplicitlyTaggedType(1, new Sequence(...$oids));
219
-        }
220
-        if (true !== $this->_permitUnSpecified) {
221
-            $elements[] = new Boolean(false);
222
-        }
223
-        return new Sequence(...$elements);
224
-    }
22
+	/**
23
+	 * Path length contraint.
24
+	 *
25
+	 * @var null|int
26
+	 */
27
+	protected $_pathLenConstraint;
28
+
29
+	/**
30
+	 * Permitted attributes.
31
+	 *
32
+	 * Array of OID's.
33
+	 *
34
+	 * @var null|string[]
35
+	 */
36
+	protected $_permittedAttrs;
37
+
38
+	/**
39
+	 * Excluded attributes.
40
+	 *
41
+	 * Array of OID's.
42
+	 *
43
+	 * @var null|string[]
44
+	 */
45
+	protected $_excludedAttrs;
46
+
47
+	/**
48
+	 * Whether to permit unspecified attributes.
49
+	 *
50
+	 * @var bool
51
+	 */
52
+	protected $_permitUnSpecified;
53
+
54
+	/**
55
+	 * Constructor.
56
+	 *
57
+	 * @param bool          $critical
58
+	 * @param null|int      $path_len
59
+	 * @param null|string[] $permitted
60
+	 * @param null|string[] $excluded
61
+	 * @param bool          $permit_unspecified
62
+	 */
63
+	public function __construct(bool $critical, ?int $path_len = null,
64
+		?array $permitted = null, ?array $excluded = null, bool $permit_unspecified = true)
65
+	{
66
+		parent::__construct(self::OID_AA_CONTROLS, $critical);
67
+		$this->_pathLenConstraint = $path_len;
68
+		$this->_permittedAttrs = $permitted;
69
+		$this->_excludedAttrs = $excluded;
70
+		$this->_permitUnSpecified = $permit_unspecified;
71
+	}
72
+
73
+	/**
74
+	 * Check whether path length constraint is present.
75
+	 *
76
+	 * @return bool
77
+	 */
78
+	public function hasPathLen(): bool
79
+	{
80
+		return isset($this->_pathLenConstraint);
81
+	}
82
+
83
+	/**
84
+	 * Get path length constraint.
85
+	 *
86
+	 * @throws \LogicException If not set
87
+	 *
88
+	 * @return int
89
+	 */
90
+	public function pathLen(): int
91
+	{
92
+		if (!$this->hasPathLen()) {
93
+			throw new \LogicException('pathLen not set.');
94
+		}
95
+		return $this->_pathLenConstraint;
96
+	}
97
+
98
+	/**
99
+	 * Check whether permitted attributes are present.
100
+	 *
101
+	 * @return bool
102
+	 */
103
+	public function hasPermittedAttrs(): bool
104
+	{
105
+		return isset($this->_permittedAttrs);
106
+	}
107
+
108
+	/**
109
+	 * Get OID's of permitted attributes.
110
+	 *
111
+	 * @throws \LogicException If not set
112
+	 *
113
+	 * @return string[]
114
+	 */
115
+	public function permittedAttrs(): array
116
+	{
117
+		if (!$this->hasPermittedAttrs()) {
118
+			throw new \LogicException('permittedAttrs not set.');
119
+		}
120
+		return $this->_permittedAttrs;
121
+	}
122
+
123
+	/**
124
+	 * Check whether excluded attributes are present.
125
+	 *
126
+	 * @return bool
127
+	 */
128
+	public function hasExcludedAttrs(): bool
129
+	{
130
+		return isset($this->_excludedAttrs);
131
+	}
132
+
133
+	/**
134
+	 * Get OID's of excluded attributes.
135
+	 *
136
+	 * @throws \LogicException If not set
137
+	 *
138
+	 * @return string[]
139
+	 */
140
+	public function excludedAttrs(): array
141
+	{
142
+		if (!$this->hasExcludedAttrs()) {
143
+			throw new \LogicException('excludedAttrs not set.');
144
+		}
145
+		return $this->_excludedAttrs;
146
+	}
147
+
148
+	/**
149
+	 * Whether to permit attributes that are not explicitly specified in
150
+	 * neither permitted nor excluded list.
151
+	 *
152
+	 * @return bool
153
+	 */
154
+	public function permitUnspecified(): bool
155
+	{
156
+		return $this->_permitUnSpecified;
157
+	}
158
+
159
+	/**
160
+	 * {@inheritdoc}
161
+	 */
162
+	protected static function _fromDER(string $data, bool $critical): Extension
163
+	{
164
+		$seq = UnspecifiedType::fromDER($data)->asSequence();
165
+		$path_len = null;
166
+		$permitted = null;
167
+		$excluded = null;
168
+		$permit_unspecified = true;
169
+		$idx = 0;
170
+		if ($seq->has($idx, Element::TYPE_INTEGER)) {
171
+			$path_len = $seq->at($idx++)->asInteger()->intNumber();
172
+		}
173
+		if ($seq->hasTagged(0)) {
174
+			$attr_seq = $seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)
175
+				->asSequence();
176
+			$permitted = array_map(
177
+				function (UnspecifiedType $el) {
178
+					return $el->asObjectIdentifier()->oid();
179
+				}, $attr_seq->elements());
180
+			++$idx;
181
+		}
182
+		if ($seq->hasTagged(1)) {
183
+			$attr_seq = $seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)
184
+				->asSequence();
185
+			$excluded = array_map(
186
+				function (UnspecifiedType $el) {
187
+					return $el->asObjectIdentifier()->oid();
188
+				}, $attr_seq->elements());
189
+			++$idx;
190
+		}
191
+		if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
192
+			$permit_unspecified = $seq->at($idx++)->asBoolean()->value();
193
+		}
194
+		return new self($critical, $path_len, $permitted, $excluded, $permit_unspecified);
195
+	}
196
+
197
+	/**
198
+	 * {@inheritdoc}
199
+	 */
200
+	protected function _valueASN1(): Element
201
+	{
202
+		$elements = [];
203
+		if (isset($this->_pathLenConstraint)) {
204
+			$elements[] = new Integer($this->_pathLenConstraint);
205
+		}
206
+		if (isset($this->_permittedAttrs)) {
207
+			$oids = array_map(
208
+				function ($oid) {
209
+					return new ObjectIdentifier($oid);
210
+				}, $this->_permittedAttrs);
211
+			$elements[] = new ImplicitlyTaggedType(0, new Sequence(...$oids));
212
+		}
213
+		if (isset($this->_excludedAttrs)) {
214
+			$oids = array_map(
215
+				function ($oid) {
216
+					return new ObjectIdentifier($oid);
217
+				}, $this->_excludedAttrs);
218
+			$elements[] = new ImplicitlyTaggedType(1, new Sequence(...$oids));
219
+		}
220
+		if (true !== $this->_permitUnSpecified) {
221
+			$elements[] = new Boolean(false);
222
+		}
223
+		return new Sequence(...$elements);
224
+	}
225 225
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension;
6 6
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             $attr_seq = $seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)
175 175
                 ->asSequence();
176 176
             $permitted = array_map(
177
-                function (UnspecifiedType $el) {
177
+                function(UnspecifiedType $el) {
178 178
                     return $el->asObjectIdentifier()->oid();
179 179
                 }, $attr_seq->elements());
180 180
             ++$idx;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             $attr_seq = $seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)
184 184
                 ->asSequence();
185 185
             $excluded = array_map(
186
-                function (UnspecifiedType $el) {
186
+                function(UnspecifiedType $el) {
187 187
                     return $el->asObjectIdentifier()->oid();
188 188
                 }, $attr_seq->elements());
189 189
             ++$idx;
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
         }
206 206
         if (isset($this->_permittedAttrs)) {
207 207
             $oids = array_map(
208
-                function ($oid) {
208
+                function($oid) {
209 209
                     return new ObjectIdentifier($oid);
210 210
                 }, $this->_permittedAttrs);
211 211
             $elements[] = new ImplicitlyTaggedType(0, new Sequence(...$oids));
212 212
         }
213 213
         if (isset($this->_excludedAttrs)) {
214 214
             $oids = array_map(
215
-                function ($oid) {
215
+                function($oid) {
216 216
                     return new ObjectIdentifier($oid);
217 217
                 }, $this->_excludedAttrs);
218 218
             $elements[] = new ImplicitlyTaggedType(1, new Sequence(...$oids));
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/BasicConstraintsExtension.php 2 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -17,99 +17,99 @@
 block discarded – undo
17 17
  */
18 18
 class BasicConstraintsExtension extends Extension
19 19
 {
20
-    /**
21
-     * Whether certificate is a CA.
22
-     *
23
-     * @var bool
24
-     */
25
-    protected $_ca;
20
+	/**
21
+	 * Whether certificate is a CA.
22
+	 *
23
+	 * @var bool
24
+	 */
25
+	protected $_ca;
26 26
 
27
-    /**
28
-     * Maximum certification path length.
29
-     *
30
-     * @var null|int
31
-     */
32
-    protected $_pathLen;
27
+	/**
28
+	 * Maximum certification path length.
29
+	 *
30
+	 * @var null|int
31
+	 */
32
+	protected $_pathLen;
33 33
 
34
-    /**
35
-     * Constructor.
36
-     *
37
-     * @param bool     $critical
38
-     * @param bool     $ca
39
-     * @param null|int $path_len
40
-     */
41
-    public function __construct(bool $critical, bool $ca, ?int $path_len = null)
42
-    {
43
-        parent::__construct(self::OID_BASIC_CONSTRAINTS, $critical);
44
-        $this->_ca = $ca;
45
-        $this->_pathLen = $path_len;
46
-    }
34
+	/**
35
+	 * Constructor.
36
+	 *
37
+	 * @param bool     $critical
38
+	 * @param bool     $ca
39
+	 * @param null|int $path_len
40
+	 */
41
+	public function __construct(bool $critical, bool $ca, ?int $path_len = null)
42
+	{
43
+		parent::__construct(self::OID_BASIC_CONSTRAINTS, $critical);
44
+		$this->_ca = $ca;
45
+		$this->_pathLen = $path_len;
46
+	}
47 47
 
48
-    /**
49
-     * Whether certificate is a CA.
50
-     *
51
-     * @return bool
52
-     */
53
-    public function isCA(): bool
54
-    {
55
-        return $this->_ca;
56
-    }
48
+	/**
49
+	 * Whether certificate is a CA.
50
+	 *
51
+	 * @return bool
52
+	 */
53
+	public function isCA(): bool
54
+	{
55
+		return $this->_ca;
56
+	}
57 57
 
58
-    /**
59
-     * Whether path length is present.
60
-     *
61
-     * @return bool
62
-     */
63
-    public function hasPathLen(): bool
64
-    {
65
-        return isset($this->_pathLen);
66
-    }
58
+	/**
59
+	 * Whether path length is present.
60
+	 *
61
+	 * @return bool
62
+	 */
63
+	public function hasPathLen(): bool
64
+	{
65
+		return isset($this->_pathLen);
66
+	}
67 67
 
68
-    /**
69
-     * Get path length.
70
-     *
71
-     * @throws \LogicException If not set
72
-     *
73
-     * @return int
74
-     */
75
-    public function pathLen(): int
76
-    {
77
-        if (!$this->hasPathLen()) {
78
-            throw new \LogicException('pathLenConstraint not set.');
79
-        }
80
-        return $this->_pathLen;
81
-    }
68
+	/**
69
+	 * Get path length.
70
+	 *
71
+	 * @throws \LogicException If not set
72
+	 *
73
+	 * @return int
74
+	 */
75
+	public function pathLen(): int
76
+	{
77
+		if (!$this->hasPathLen()) {
78
+			throw new \LogicException('pathLenConstraint not set.');
79
+		}
80
+		return $this->_pathLen;
81
+	}
82 82
 
83
-    /**
84
-     * {@inheritdoc}
85
-     */
86
-    protected static function _fromDER(string $data, bool $critical): Extension
87
-    {
88
-        $seq = UnspecifiedType::fromDER($data)->asSequence();
89
-        $ca = false;
90
-        $path_len = null;
91
-        $idx = 0;
92
-        if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
93
-            $ca = $seq->at($idx++)->asBoolean()->value();
94
-        }
95
-        if ($seq->has($idx, Element::TYPE_INTEGER)) {
96
-            $path_len = $seq->at($idx)->asInteger()->intNumber();
97
-        }
98
-        return new self($critical, $ca, $path_len);
99
-    }
83
+	/**
84
+	 * {@inheritdoc}
85
+	 */
86
+	protected static function _fromDER(string $data, bool $critical): Extension
87
+	{
88
+		$seq = UnspecifiedType::fromDER($data)->asSequence();
89
+		$ca = false;
90
+		$path_len = null;
91
+		$idx = 0;
92
+		if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
93
+			$ca = $seq->at($idx++)->asBoolean()->value();
94
+		}
95
+		if ($seq->has($idx, Element::TYPE_INTEGER)) {
96
+			$path_len = $seq->at($idx)->asInteger()->intNumber();
97
+		}
98
+		return new self($critical, $ca, $path_len);
99
+	}
100 100
 
101
-    /**
102
-     * {@inheritdoc}
103
-     */
104
-    protected function _valueASN1(): Element
105
-    {
106
-        $elements = [];
107
-        if ($this->_ca) {
108
-            $elements[] = new Boolean(true);
109
-        }
110
-        if (isset($this->_pathLen)) {
111
-            $elements[] = new Integer($this->_pathLen);
112
-        }
113
-        return new Sequence(...$elements);
114
-    }
101
+	/**
102
+	 * {@inheritdoc}
103
+	 */
104
+	protected function _valueASN1(): Element
105
+	{
106
+		$elements = [];
107
+		if ($this->_ca) {
108
+			$elements[] = new Boolean(true);
109
+		}
110
+		if (isset($this->_pathLen)) {
111
+			$elements[] = new Integer($this->_pathLen);
112
+		}
113
+		return new Sequence(...$elements);
114
+	}
115 115
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 namespace Sop\X509\Certificate\Extension;
6 6
 
Please login to merge, or discard this patch.