Completed
Push — master ( a51466...8daf75 )
by Raffael
02:47
created
src/Auth.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 /**
5 5
  * Micro
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      * @param   Logger $logger
66 66
      * @return  void
67 67
      */
68
-    public function __construct(?Iterable $config=null, Logger $logger)
68
+    public function __construct(? Iterable $config = null, Logger $logger)
69 69
     {
70 70
         $this->logger = $logger;
71 71
         $this->setOptions($config);
@@ -78,27 +78,27 @@  discard block
 block discarded – undo
78 78
      * @param  Iterable $config
79 79
      * @return Log
80 80
      */
81
-    public function setOptions(?Iterable $config=null): Auth
81
+    public function setOptions(? Iterable $config = null) : Auth
82 82
     {
83
-        if($config === null) {
83
+        if ($config === null) {
84 84
             return $this;
85 85
         }
86 86
 
87
-        foreach($config as $option => $value) {
88
-            switch($option) {
87
+        foreach ($config as $option => $value) {
88
+            switch ($option) {
89 89
                 case 'identity_class': 
90 90
                 case 'attribute_map_class': 
91 91
                     $this->{$option} = (string)$value;
92 92
                 break;
93 93
 
94 94
                 case 'adapter':
95
-                    foreach($value as $name => $adapter) {
96
-                        if(!isset($adapter['enabled']) || $adapter['enabled'] === '1') {
97
-                            if(!isset($adapter['class'])) {
95
+                    foreach ($value as $name => $adapter) {
96
+                        if (!isset($adapter['enabled']) || $adapter['enabled'] === '1') {
97
+                            if (!isset($adapter['class'])) {
98 98
                                 throw new Exception('class option is required');
99 99
                             }
100 100
                         
101
-                            if(isset($adapter['config'])) {
101
+                            if (isset($adapter['config'])) {
102 102
                                 $config = $adapter['config'];
103 103
                             } else {
104 104
                                 $config = null;
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
      * @param  Iterable $config
139 139
      * @return AdapterInterface
140 140
      */
141
-    public function addAdapter(string $name, string $class, ?Iterable $config=null): AdapterInterface
141
+    public function addAdapter(string $name, string $class, ? Iterable $config = null) : AdapterInterface
142 142
     {
143
-        if($this->hasAdapter($name)) {
143
+        if ($this->hasAdapter($name)) {
144 144
             throw new Exception('auth adapter '.$name.' is already registered');
145 145
         }
146 146
             
147 147
         $adapter = new $class($config, $this->logger);
148
-        if(!($adapter instanceof AdapterInterface)) {
148
+        if (!($adapter instanceof AdapterInterface)) {
149 149
             throw new Exception('auth adapter must include AdapterInterface interface');
150 150
         }
151 151
         $this->adapter[$name] = $adapter;
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function getAdapter(string $name): AdapterInterface
163 163
     {
164
-        if(!$this->hasAdapter($name)) {
164
+        if (!$this->hasAdapter($name)) {
165 165
             throw new Exception('auth adapter '.$name.' is not registered');
166 166
         }
167 167
 
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
      * @param  array $adapters
176 176
      * @return array
177 177
      */
178
-    public function getAdapters(array $adapters=[]): array
178
+    public function getAdapters(array $adapters = []): array
179 179
     {
180
-        if(empty($adapter)) {
180
+        if (empty($adapter)) {
181 181
             return $this->adapter;
182 182
         } else {
183 183
             $list = [];
184
-            foreach($adapter as $name) {
185
-                if(!$this->hasAdapter($name)) {
184
+            foreach ($adapter as $name) {
185
+                if (!$this->hasAdapter($name)) {
186 186
                     throw new Exception('auth adapter '.$name.' is not registered');
187 187
                 }
188 188
                 $list[$name] = $this->adapter[$name];
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     {
218 218
         $result = false;
219 219
         
220
-        foreach($this->adapter as $name => $adapter) {
220
+        foreach ($this->adapter as $name => $adapter) {
221 221
             try {
222 222
                 if ($adapter->authenticate()) {
223 223
                     $this->createIdentity($adapter);      
Please login to merge, or discard this patch.