Completed
Push — master ( a51466...8daf75 )
by Raffael
02:47
created
tests/MockLogger.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 {
8 8
     public $storage = [];
9 9
 
10
-    public function log($level, $message, array $context=[])
10
+    public function log($level, $message, array $context = [])
11 11
     {
12 12
         $this->storage[] = [
13 13
             'level'     => $level,
Please login to merge, or discard this patch.
src/Log.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
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @param   Iterable $config
58 58
      * @return  void
59 59
      */
60
-    public function __construct(?Iterable $config=null)
60
+    public function __construct(? Iterable $config = null)
61 61
     {
62 62
         $this->setOptions($config);
63 63
     }
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
      * @param  Iterable $config
70 70
      * @return Log
71 71
      */
72
-    public function setOptions(?Iterable $config=null)
72
+    public function setOptions(? Iterable $config = null)
73 73
     {
74
-        if($config === null) {
74
+        if ($config === null) {
75 75
             return $this;
76 76
         }
77 77
 
78
-        foreach($config as $option => $value) {
79
-            if(!isset($value['enabled']) || $value['enabled'] === '1') {
78
+        foreach ($config as $option => $value) {
79
+            if (!isset($value['enabled']) || $value['enabled'] === '1') {
80 80
                 $this->addAdapter($option, $value['class'], $value['config']);
81 81
             }
82 82
         }
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
      * @param  Iterable $config
106 106
      * @return AdapterInterface
107 107
      */
108
-    public function addAdapter(string $name, string $class, ?Iterable $config=null): AdapterInterface
108
+    public function addAdapter(string $name, string $class, ? Iterable $config = null) : AdapterInterface
109 109
     {
110
-        if($this->hasAdapter($name)) {
110
+        if ($this->hasAdapter($name)) {
111 111
             throw new Exception('log adapter '.$name.' is already registered');
112 112
         }
113 113
             
114 114
         $adapter = new $class($config);
115
-        if(!($adapter instanceof AdapterInterface)) {
115
+        if (!($adapter instanceof AdapterInterface)) {
116 116
             throw new Exception('log adapter must include AdapterInterface interface');
117 117
         }
118 118
         $this->adapter[$name] = $adapter;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     public function getAdapter(string $name): AdapterInterface
130 130
     {
131
-        if(!$this->hasAdapter($name)) {
131
+        if (!$this->hasAdapter($name)) {
132 132
             throw new Exception('log adapter '.$name.' is not registered');
133 133
         }
134 134
 
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
      * @param  array $adapters
143 143
      * @return array
144 144
      */
145
-    public function getAdapters(array $adapters=[]): array
145
+    public function getAdapters(array $adapters = []): array
146 146
     {
147
-        if(empty($adapter)) {
147
+        if (empty($adapter)) {
148 148
             return $this->adapter;
149 149
         } else {
150 150
             $list = [];
151
-            foreach($adapter as $name) {
152
-                if(!$this->hasAdapter($name)) {
151
+            foreach ($adapter as $name) {
152
+                if (!$this->hasAdapter($name)) {
153 153
                     throw new Exception('log adapter '.$name.' is not registered');
154 154
                 }
155 155
                 $list[$name] = $this->adapter[$name];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      * @param   array $context
170 170
      * @return  bool
171 171
      */
172
-    public function log($level, $message, array $context=[]): bool
172
+    public function log($level, $message, array $context = []): bool
173 173
     {
174 174
         if (!array_key_exists($level, self::PRIORITIES)) {
175 175
             throw new Exception('log level '.$level.' is unkown');
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
      * @param   array $context
213 213
      * @return  void
214 214
      */
215
-    protected function _format(string $message, string $format, string $date_format, string $level, array $context=[]): string
215
+    protected function _format(string $message, string $format, string $date_format, string $level, array $context = []): string
216 216
     {
217
-        $parsed = preg_replace_callback('/(\{(([a-z]\.*)+)\})/', function ($match) use ($message, $level, $date_format, $context) {
217
+        $parsed = preg_replace_callback('/(\{(([a-z]\.*)+)\})/', function($match) use ($message, $level, $date_format, $context) {
218 218
             $key = '';
219 219
             $context = array_merge($this->context, $context);
220 220
                     
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
                     $replace = [];
238 238
                     foreach ($context as $key => $val) {
239 239
                         if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) {
240
-                            $replace['{' . $key . '}'] = $val;
240
+                            $replace['{'.$key.'}'] = $val;
241 241
                         } else {
242
-                            $replace['{' . $key . '}'] = json_encode($val);
242
+                            $replace['{'.$key.'}'] = json_encode($val);
243 243
                         }
244 244
                     }
245 245
 
Please login to merge, or discard this patch.
src/Log/Adapter/File.php 1 patch
Spacing   +3 added lines, -3 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
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * @param   Iterable $options
35 35
      * @return  AdapterInterface
36 36
      */
37
-    public function setOptions(?Iterable $config=null): AdapterInterface
37
+    public function setOptions(? Iterable $config = null) : AdapterInterface
38 38
     {
39 39
         parent::setOptions($config);
40 40
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function log(string $priority, string $message): bool
67 67
     {
68
-        if(!is_resource($this->resource)) {
68
+        if (!is_resource($this->resource)) {
69 69
             return false;
70 70
         }
71 71
 
Please login to merge, or discard this patch.
src/Ldap.php 1 patch
Spacing   +7 added lines, -7 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
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      *
69 69
      * @var bool
70 70
      */
71
-    protected $tls=false;
71
+    protected $tls = false;
72 72
 
73 73
 
74 74
     /**
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      * @param   Logger $logger
87 87
      * @return  resource
88 88
      */
89
-    public function __construct(?Iterable $config, Logger $logger)
89
+    public function __construct(? Iterable $config, Logger $logger)
90 90
     {
91 91
         $this->setOptions($config);
92 92
         $this->logger = $logger;
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public function connect(): Ldap
102 102
     {
103
-        if($this->binddn === null) {
103
+        if ($this->binddn === null) {
104 104
             $this->logger->warning('no binddn set for ldap connection, you should avoid anonymous bind', [
105 105
                 'category' => get_class($this),
106 106
             ]);
107 107
         }
108 108
         
109
-        if($this->tls === false && substr($this->uri, 0, 5) !== 'ldaps') {
109
+        if ($this->tls === false && substr($this->uri, 0, 5) !== 'ldaps') {
110 110
             $this->logger->warning('neither tls nor ldaps enabled for ldap connection, it is strongly reccommended to encrypt ldap connections', [
111 111
                 'category' => get_class($this),
112 112
             ]);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         }
124 124
 
125 125
         if ($this->connection) {
126
-            if($this->binddn !== null) {
126
+            if ($this->binddn !== null) {
127 127
                 $bind = ldap_bind($this->connection, $this->binddn, $this->bindpw);
128 128
 
129 129
                 if ($bind) {
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      * @param  Iterable $config
166 166
      * @return Ldap
167 167
      */
168
-    public function setOptions(?Iterable $config=null): Ldap
168
+    public function setOptions(? Iterable $config = null) : Ldap
169 169
     {
170 170
         if ($config === null) {
171 171
             return $this;
Please login to merge, or discard this patch.
src/Auth/Exception.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 /**
5 5
  * Micro
Please login to merge, or discard this patch.
src/Auth/Adapter/AbstractAdapter.php 1 patch
Spacing   +3 added lines, -3 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
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @param   Logger $logger
48 48
      * @return  void
49 49
      */
50
-    public function __construct(?Iterable $config, Logger $logger)
50
+    public function __construct(? Iterable $config, Logger $logger)
51 51
     {
52 52
         $this->logger = $logger;
53 53
         $this->setOptions($config);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      * @param   Iterable $config
72 72
      * @return  AdapterInterface
73 73
      */
74
-    public function setOptions(?Iterable $config=null): AdapterInterface
74
+    public function setOptions(? Iterable $config = null) : AdapterInterface
75 75
     {
76 76
         if ($config === null) {
77 77
             return $this;
Please login to merge, or discard this patch.
src/Auth/Adapter/None.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 /**
5 5
  * Micro
Please login to merge, or discard this patch.
src/Auth/Adapter/LdapPreauth.php 1 patch
Spacing   +5 added lines, -5 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
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      * @param   Iterable $config
39 39
      * @return  LdapServer
40 40
      */
41
-    public function setOptions(?Iterable $config=null): LdapServer
41
+    public function setOptions(? Iterable $config = null) : LdapServer
42 42
     {
43 43
         if ($config === null) {
44 44
             return $this;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      */
107 107
     protected function preauth(string $value): bool
108 108
     {
109
-        $parts   = explode('|', $value);
109
+        $parts = explode('|', $value);
110 110
 
111 111
         if (count($parts) !== 2) {
112 112
             $this->logger->warning('invalid header x-preauth value, parts != 2', [
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
             'category' => get_class($this)
194 194
         ]);
195 195
 
196
-        $this->ldap_dn   = $dn;
196
+        $this->ldap_dn = $dn;
197 197
 
198 198
         return true;
199 199
     }
@@ -218,6 +218,6 @@  discard block
 block discarded – undo
218 218
         $ip_decimal = ip2long($ip);
219 219
         $wildcard_decimal = pow(2, (32 - $netmask)) - 1;
220 220
         $netmask_decimal = ~ $wildcard_decimal;
221
-        return (($ip_decimal & $netmask_decimal) == ($range_decimal & $netmask_decimal));
221
+        return (($ip_decimal&$netmask_decimal) == ($range_decimal&$netmask_decimal));
222 222
     }
223 223
 }
Please login to merge, or discard this patch.
src/Auth/Adapter/Oidc.php 1 patch
Spacing   +6 added lines, -6 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
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
      * @param   Iterable $config
36 36
      * @return  AdapterInterface
37 37
      */
38
-    public function setOptions(?Iterable $config=null): AdapterInterface
38
+    public function setOptions(? Iterable $config = null) : AdapterInterface
39 39
     {
40 40
         if ($config === null) {
41 41
             return $this;
42 42
         }
43 43
 
44
-        if(isset($config['provider_url'])) {
44
+        if (isset($config['provider_url'])) {
45 45
             $this->discovery_url = (string)$config['provider_url'];
46 46
         }
47 47
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */    
102 102
     protected function getDiscoveryDocument(): array
103 103
     {
104
-        if($apc = extension_loaded('apc') && apc_exists($this->provider_url)) {
104
+        if ($apc = extension_loaded('apc') && apc_exists($this->provider_url)) {
105 105
             return apc_get($this->provider_url);
106 106
         } else {
107 107
             $ch = curl_init();
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
             $discovery = json_decode($result, true);
113 113
             
114
-            if($apc === true) {
114
+            if ($apc === true) {
115 115
                 apc_store($this->provider_url, $discovery);
116 116
             }
117 117
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     protected function verifyToken(string $token): bool
130 130
     {
131 131
         $discovery = $this->getDiscoverDocument();
132
-        if(!(isset($discovery['authorization_endpoint']))) {
132
+        if (!(isset($discovery['authorization_endpoint']))) {
133 133
             throw new Exception('authorization_endpoint could not be determained');
134 134
         }
135 135
 
Please login to merge, or discard this patch.