@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | return []; |
207 | 207 | } |
208 | 208 | |
209 | - $policy = new FeaturePermissionPolicy($config); |
|
209 | + $policy = new FeaturePermissionPolicy($config); |
|
210 | 210 | |
211 | 211 | return ['Permissions-Policy' => $policy->headers()]; |
212 | 212 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | return []; |
224 | 224 | } |
225 | 225 | |
226 | - $policy = new StrictTransportSecurityPolicy($config); |
|
226 | + $policy = new StrictTransportSecurityPolicy($config); |
|
227 | 227 | |
228 | 228 | return ['Strict-Transport-Security' => $policy->headers()]; |
229 | 229 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | return []; |
242 | 242 | } |
243 | 243 | |
244 | - $policy = new ClearSiteDataPolicy($config); |
|
244 | + $policy = new ClearSiteDataPolicy($config); |
|
245 | 245 | |
246 | 246 | return ['Clear-Site-Data' => $policy->headers()]; |
247 | 247 | } |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | * @package Platine\Framework\Security |
62 | 62 | * @template T |
63 | 63 | */ |
64 | -class SecurityPolicy |
|
65 | -{ |
|
64 | +class SecurityPolicy { |
|
66 | 65 | /** |
67 | 66 | * The application configuration |
68 | 67 | * @var Config<T> |
@@ -101,7 +100,7 @@ discard block |
||
101 | 100 | Config $config, |
102 | 101 | Router $router, |
103 | 102 | array $configurations = [] |
104 | - ) { |
|
103 | + ) { |
|
105 | 104 | $this->config = $config; |
106 | 105 | $this->router = $router; |
107 | 106 | $this->configurations = $configurations; |
@@ -145,18 +144,18 @@ discard block |
||
145 | 144 | { |
146 | 145 | $config = $this->configurations['csp'] ?? []; |
147 | 146 | $isEnabled = $config['enable'] ?? false; |
148 | - if ($isEnabled === false) { |
|
147 | + if ($isEnabled === false) { |
|
149 | 148 | return []; |
150 | 149 | } |
151 | 150 | |
152 | 151 | $config['script-src']['nonces'] = $this->nonces['script']; |
153 | 152 | $config['style-src']['nonces'] = $this->nonces['style']; |
154 | 153 | |
155 | - if (count($config['report-uri'] ?? []) > 0) { |
|
154 | + if (count($config['report-uri'] ?? []) > 0) { |
|
156 | 155 | $routes = $this->router->routes(); |
157 | 156 | $reportUri = []; |
158 | - foreach ($config['report-uri'] as $url) { |
|
159 | - if ($routes->has($url)) { |
|
157 | + foreach ($config['report-uri'] as $url) { |
|
158 | + if ($routes->has($url)) { |
|
160 | 159 | $url = $this->config->get('app.host') . $this->router->getUri($url)->getPath(); |
161 | 160 | } |
162 | 161 | |
@@ -176,13 +175,13 @@ discard block |
||
176 | 175 | $headers = [$header => $policy->headers()]; |
177 | 176 | |
178 | 177 | $reportTo = []; |
179 | - if ($config['report-to'] ?? false) { |
|
180 | - if (count($config['report-uri'] ?? []) > 0) { |
|
178 | + if ($config['report-to'] ?? false) { |
|
179 | + if (count($config['report-uri'] ?? []) > 0) { |
|
181 | 180 | $reportTo['group'] = $config['report-to']; |
182 | 181 | $reportTo['max_age'] = 1800; // TODO use configuration |
183 | 182 | |
184 | 183 | $reportTo['endpoints'] = []; |
185 | - foreach ($config['report-uri'] as $url) { |
|
184 | + foreach ($config['report-uri'] as $url) { |
|
186 | 185 | $reportTo['endpoints'][] = [ |
187 | 186 | 'url' => $url |
188 | 187 | ]; |
@@ -202,7 +201,7 @@ discard block |
||
202 | 201 | { |
203 | 202 | $config = $this->configurations['features-permissions'] ?? []; |
204 | 203 | $isEnabled = $config['enable'] ?? false; |
205 | - if ($isEnabled === false) { |
|
204 | + if ($isEnabled === false) { |
|
206 | 205 | return []; |
207 | 206 | } |
208 | 207 | |
@@ -219,7 +218,7 @@ discard block |
||
219 | 218 | { |
220 | 219 | $config = $this->configurations['hsts'] ?? []; |
221 | 220 | $isEnabled = $config['enable'] ?? false; |
222 | - if ($isEnabled === false) { |
|
221 | + if ($isEnabled === false) { |
|
223 | 222 | return []; |
224 | 223 | } |
225 | 224 | |
@@ -237,7 +236,7 @@ discard block |
||
237 | 236 | { |
238 | 237 | $config = $this->configurations['clear-site-data'] ?? []; |
239 | 238 | $isEnabled = $config['enable'] ?? false; |
240 | - if ($isEnabled === false) { |
|
239 | + if ($isEnabled === false) { |
|
241 | 240 | return []; |
242 | 241 | } |
243 | 242 |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @class CsrfStorageInterface |
52 | 52 | * @package Platine\Framework\Security\Csrf |
53 | 53 | */ |
54 | -interface CsrfStorageInterface |
|
55 | -{ |
|
54 | +interface CsrfStorageInterface { |
|
56 | 55 | /** |
57 | 56 | * Return the token information from storage |
58 | 57 | * @param string $name |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @class CsrfUserSessionStorage |
52 | 52 | * @package Platine\Framework\Security\Csrf\Storage |
53 | 53 | */ |
54 | -class CsrfUserSessionStorage extends CsrfSessionStorage |
|
55 | -{ |
|
54 | +class CsrfUserSessionStorage extends CsrfSessionStorage { |
|
56 | 55 | /** |
57 | 56 | * {@inheritdoc} |
58 | 57 | */ |
@@ -74,7 +74,7 @@ |
||
74 | 74 | */ |
75 | 75 | public function set(string $name, string $token, int $expire): void |
76 | 76 | { |
77 | - $this->data[$name] = $token; |
|
77 | + $this->data[$name] = $token; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -53,8 +53,7 @@ |
||
53 | 53 | * @class CsrfNullStorage |
54 | 54 | * @package Platine\Framework\Security\Csrf\Storage |
55 | 55 | */ |
56 | -class CsrfNullStorage implements CsrfStorageInterface |
|
57 | -{ |
|
56 | +class CsrfNullStorage implements CsrfStorageInterface { |
|
58 | 57 | /** |
59 | 58 | * The CSRF data |
60 | 59 | * @var array<string, string> |
@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * @class CsrfSessionStorage |
55 | 55 | * @package Platine\Framework\Security\Csrf\Storage |
56 | 56 | */ |
57 | -class CsrfSessionStorage implements CsrfStorageInterface |
|
58 | -{ |
|
57 | +class CsrfSessionStorage implements CsrfStorageInterface { |
|
59 | 58 | /** |
60 | 59 | * The session key used to store CSRF data |
61 | 60 | */ |
@@ -72,8 +71,7 @@ discard block |
||
72 | 71 | * Create new instance |
73 | 72 | * @param Session $session |
74 | 73 | */ |
75 | - public function __construct(Session $session) |
|
76 | - { |
|
74 | + public function __construct(Session $session) { |
|
77 | 75 | $this->session = $session; |
78 | 76 | } |
79 | 77 | |
@@ -86,7 +84,7 @@ discard block |
||
86 | 84 | $key = $this->getKeyName($name); |
87 | 85 | $data = $this->session->get($key, []); |
88 | 86 | |
89 | - if (count($data) === 0 || $data['expire'] <= time()) { |
|
87 | + if (count($data) === 0 || $data['expire'] <= time()) { |
|
90 | 88 | return null; |
91 | 89 | } |
92 | 90 |
@@ -83,7 +83,7 @@ |
||
83 | 83 | ?CsrfStorageInterface $storage = null |
84 | 84 | ) { |
85 | 85 | $this->config = $config; |
86 | - $this->storage = $storage ?? new CsrfNullStorage(); |
|
86 | + $this->storage = $storage ?? new CsrfNullStorage(); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | * @package Platine\Framework\Security\Csrf |
60 | 60 | * @template T |
61 | 61 | */ |
62 | -class CsrfManager |
|
63 | -{ |
|
62 | +class CsrfManager { |
|
64 | 63 | /** |
65 | 64 | * The application configuration class |
66 | 65 | * @var Config<T> |
@@ -81,7 +80,7 @@ discard block |
||
81 | 80 | public function __construct( |
82 | 81 | Config $config, |
83 | 82 | ?CsrfStorageInterface $storage = null |
84 | - ) { |
|
83 | + ) { |
|
85 | 84 | $this->config = $config; |
86 | 85 | $this->storage = $storage ?? new CsrfNullStorage(); |
87 | 86 | } |
@@ -94,18 +93,18 @@ discard block |
||
94 | 93 | */ |
95 | 94 | public function validate(ServerRequestInterface $request, ?string $key = null): bool |
96 | 95 | { |
97 | - if ($key === null) { |
|
96 | + if ($key === null) { |
|
98 | 97 | $key = $this->getConfigValue('key'); |
99 | 98 | } |
100 | 99 | |
101 | 100 | $storageToken = $this->storage->get($key); |
102 | - if ($storageToken === null) { |
|
101 | + if ($storageToken === null) { |
|
103 | 102 | return false; |
104 | 103 | } |
105 | 104 | |
106 | 105 | $token = $this->getRequestToken($request, $key); |
107 | 106 | |
108 | - if ($token === null || $token !== $storageToken) { |
|
107 | + if ($token === null || $token !== $storageToken) { |
|
109 | 108 | return false; |
110 | 109 | } |
111 | 110 | |
@@ -119,12 +118,12 @@ discard block |
||
119 | 118 | */ |
120 | 119 | public function getToken(?string $key = null): string |
121 | 120 | { |
122 | - if ($key === null) { |
|
121 | + if ($key === null) { |
|
123 | 122 | $key = $this->getConfigValue('key'); |
124 | 123 | } |
125 | 124 | |
126 | 125 | $value = $this->storage->get($key); |
127 | - if ($value === null) { |
|
126 | + if ($value === null) { |
|
128 | 127 | // Generate the token |
129 | 128 | $value = sha1(Str::randomToken(24)); |
130 | 129 | $expire = $this->getConfigValue('expire') ?? 300; |
@@ -145,7 +144,7 @@ discard block |
||
145 | 144 | { |
146 | 145 | $token = $this->getToken($key); |
147 | 146 | |
148 | - if ($key === null) { |
|
147 | + if ($key === null) { |
|
149 | 148 | $key = (string) $this->getConfigValue('key'); |
150 | 149 | } |
151 | 150 | |
@@ -171,11 +170,11 @@ discard block |
||
171 | 170 | { |
172 | 171 | $param = new RequestData($request); |
173 | 172 | $token = $param->post($key); |
174 | - if ($token === null) { |
|
173 | + if ($token === null) { |
|
175 | 174 | $token = $param->get($key); |
176 | 175 | } |
177 | 176 | |
178 | - if ($token === null) { |
|
177 | + if ($token === null) { |
|
179 | 178 | $token = $request->getHeaderLine('X-Csrf-Token'); |
180 | 179 | } |
181 | 180 | |
@@ -188,8 +187,7 @@ discard block |
||
188 | 187 | * @param string $key |
189 | 188 | * @return mixed |
190 | 189 | */ |
191 | - private function getConfigValue(string $key) |
|
192 | - { |
|
190 | + private function getConfigValue(string $key) { |
|
193 | 191 | $config = $this->config->get('security.csrf', []); |
194 | 192 | |
195 | 193 | return $config[$key] ?? null; |
@@ -111,7 +111,7 @@ |
||
111 | 111 | // ensure indexes are numerically |
112 | 112 | $urls = array_values($values); |
113 | 113 | |
114 | - return array_map(function (string $url) { |
|
114 | + return array_map(function(string $url) { |
|
115 | 115 | return sprintf('"%s"', $url); |
116 | 116 | }, $urls); |
117 | 117 | } |
@@ -52,16 +52,15 @@ discard block |
||
52 | 52 | * @class FeaturePermissionPolicy |
53 | 53 | * @package Platine\Framework\Security\Policy |
54 | 54 | */ |
55 | -class FeaturePermissionPolicy extends AbstractPolicy |
|
56 | -{ |
|
55 | +class FeaturePermissionPolicy extends AbstractPolicy { |
|
57 | 56 | /** |
58 | 57 | * {@inheritdoc} |
59 | 58 | */ |
60 | 59 | public function headers(): string |
61 | 60 | { |
62 | 61 | $headers = []; |
63 | - foreach ($this->configurations as $name => $config) { |
|
64 | - if ($name === 'enable') { |
|
62 | + foreach ($this->configurations as $name => $config) { |
|
63 | + if ($name === 'enable') { |
|
65 | 64 | continue; |
66 | 65 | } |
67 | 66 | |
@@ -80,14 +79,14 @@ discard block |
||
80 | 79 | */ |
81 | 80 | public function directive(array $config): string |
82 | 81 | { |
83 | - if ($config['none'] ?? false) { |
|
82 | + if ($config['none'] ?? false) { |
|
84 | 83 | return '()'; |
85 | - } elseif ($config['*'] ?? false) { |
|
84 | + } elseif ($config['*'] ?? false) { |
|
86 | 85 | return '*'; |
87 | 86 | } |
88 | 87 | |
89 | 88 | $origins = $this->origins($config['origins'] ?? []); |
90 | - if ($config['self'] ?? false) { |
|
89 | + if ($config['self'] ?? false) { |
|
91 | 90 | array_unshift($origins, 'self'); |
92 | 91 | } |
93 | 92 | |
@@ -111,7 +110,7 @@ discard block |
||
111 | 110 | // ensure indexes are numerically |
112 | 111 | $urls = array_values($values); |
113 | 112 | |
114 | - return array_map(function (string $url) { |
|
113 | + return array_map(function (string $url) { |
|
115 | 114 | return sprintf('"%s"', $url); |
116 | 115 | }, $urls); |
117 | 116 | } |
@@ -79,7 +79,7 @@ |
||
79 | 79 | $directives = array_intersect_key($config, $this->whitelist); |
80 | 80 | $values = array_filter($directives); |
81 | 81 | |
82 | - $results = array_map(function (string $directive) { |
|
82 | + $results = array_map(function(string $directive) { |
|
83 | 83 | if ($directive === 'execution-contexts') { |
84 | 84 | $directive = 'executionContexts'; |
85 | 85 | } |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * @class ClearSiteDataPolicy |
53 | 53 | * @package Platine\Framework\Security\Policy |
54 | 54 | */ |
55 | -class ClearSiteDataPolicy extends AbstractPolicy |
|
56 | -{ |
|
55 | +class ClearSiteDataPolicy extends AbstractPolicy { |
|
57 | 56 | /** |
58 | 57 | * Clear Site Data white list directives. |
59 | 58 | * @var array<string, bool> |
@@ -72,15 +71,15 @@ discard block |
||
72 | 71 | { |
73 | 72 | $config = $this->configurations; |
74 | 73 | |
75 | - if ($config['all'] ?? false) { |
|
74 | + if ($config['all'] ?? false) { |
|
76 | 75 | return '"*"'; |
77 | 76 | } |
78 | 77 | |
79 | 78 | $directives = array_intersect_key($config, $this->whitelist); |
80 | 79 | $values = array_filter($directives); |
81 | 80 | |
82 | - $results = array_map(function (string $directive) { |
|
83 | - if ($directive === 'execution-contexts') { |
|
81 | + $results = array_map(function (string $directive) { |
|
82 | + if ($directive === 'execution-contexts') { |
|
84 | 83 | $directive = 'executionContexts'; |
85 | 84 | } |
86 | 85 |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | $filtered = $this->filter($config, $whitelist); |
147 | 147 | |
148 | - return array_map(function (string $keyword) { |
|
148 | + return array_map(function(string $keyword) { |
|
149 | 149 | return sprintf('\'%s\'', $keyword); |
150 | 150 | }, $filtered); |
151 | 151 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function schemes(array $schemes): array |
159 | 159 | { |
160 | - return array_map(function (string $scheme) { |
|
160 | + return array_map(function(string $scheme) { |
|
161 | 161 | $clean = trim($scheme); |
162 | 162 | |
163 | 163 | if (substr($clean, -1) === ':') { |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function nonces(array $nonces): array |
177 | 177 | { |
178 | - return array_map(function (string $nonce) { |
|
178 | + return array_map(function(string $nonce) { |
|
179 | 179 | $clean = trim($nonce); |
180 | 180 | |
181 | 181 | if (base64_decode($clean, true) === false) { |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | { |
223 | 223 | $pluginTypes = $this->configurations['plugin-types'] ?? []; |
224 | 224 | |
225 | - $filtered = array_filter($pluginTypes, function (string $mime) { |
|
225 | + $filtered = array_filter($pluginTypes, function(string $mime) { |
|
226 | 226 | return preg_match('/^[a-z\-]+\/[a-z\-]+$/i', $mime); |
227 | 227 | }); |
228 | 228 |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * @class ContentSecurityPolicy |
53 | 53 | * @package Platine\Framework\Security\Policy |
54 | 54 | */ |
55 | -class ContentSecurityPolicy extends AbstractPolicy |
|
56 | -{ |
|
55 | +class ContentSecurityPolicy extends AbstractPolicy { |
|
57 | 56 | /** |
58 | 57 | * Content Security Policy white list directives. |
59 | 58 | * @var array<string, bool> |
@@ -109,7 +108,7 @@ discard block |
||
109 | 108 | */ |
110 | 109 | public function directive(array $config): string |
111 | 110 | { |
112 | - if ($config['none'] ?? false) { |
|
111 | + if ($config['none'] ?? false) { |
|
113 | 112 | return '\'none\''; |
114 | 113 | } |
115 | 114 | |
@@ -145,7 +144,7 @@ discard block |
||
145 | 144 | |
146 | 145 | $filtered = $this->filter($config, $whitelist); |
147 | 146 | |
148 | - return array_map(function (string $keyword) { |
|
147 | + return array_map(function (string $keyword) { |
|
149 | 148 | return sprintf('\'%s\'', $keyword); |
150 | 149 | }, $filtered); |
151 | 150 | } |
@@ -157,10 +156,10 @@ discard block |
||
157 | 156 | */ |
158 | 157 | public function schemes(array $schemes): array |
159 | 158 | { |
160 | - return array_map(function (string $scheme) { |
|
159 | + return array_map(function (string $scheme) { |
|
161 | 160 | $clean = trim($scheme); |
162 | 161 | |
163 | - if (substr($clean, -1) === ':') { |
|
162 | + if (substr($clean, -1) === ':') { |
|
164 | 163 | return $clean; |
165 | 164 | } |
166 | 165 | |
@@ -175,10 +174,10 @@ discard block |
||
175 | 174 | */ |
176 | 175 | public function nonces(array $nonces): array |
177 | 176 | { |
178 | - return array_map(function (string $nonce) { |
|
177 | + return array_map(function (string $nonce) { |
|
179 | 178 | $clean = trim($nonce); |
180 | 179 | |
181 | - if (base64_decode($clean, true) === false) { |
|
180 | + if (base64_decode($clean, true) === false) { |
|
182 | 181 | return ''; |
183 | 182 | } |
184 | 183 | |
@@ -195,15 +194,15 @@ discard block |
||
195 | 194 | { |
196 | 195 | $result = []; |
197 | 196 | |
198 | - foreach ($groups as $hash => $items) { |
|
199 | - if (!in_array($hash, ['sha256', 'sha384', 'sha512'], true)) { |
|
197 | + foreach ($groups as $hash => $items) { |
|
198 | + if (!in_array($hash, ['sha256', 'sha384', 'sha512'], true)) { |
|
200 | 199 | continue; |
201 | 200 | } |
202 | 201 | |
203 | - foreach ($items as $item) { |
|
202 | + foreach ($items as $item) { |
|
204 | 203 | $clean = trim($item); |
205 | 204 | |
206 | - if (base64_decode($clean, true) === false) { |
|
205 | + if (base64_decode($clean, true) === false) { |
|
207 | 206 | continue; |
208 | 207 | } |
209 | 208 | |
@@ -222,11 +221,11 @@ discard block |
||
222 | 221 | { |
223 | 222 | $pluginTypes = $this->configurations['plugin-types'] ?? []; |
224 | 223 | |
225 | - $filtered = array_filter($pluginTypes, function (string $mime) { |
|
224 | + $filtered = array_filter($pluginTypes, function (string $mime) { |
|
226 | 225 | return preg_match('/^[a-z\-]+\/[a-z\-]+$/i', $mime); |
227 | 226 | }); |
228 | 227 | |
229 | - if (count($filtered) > 0) { |
|
228 | + if (count($filtered) > 0) { |
|
230 | 229 | array_unshift($filtered, 'plugin-types'); |
231 | 230 | } |
232 | 231 | |
@@ -241,7 +240,7 @@ discard block |
||
241 | 240 | { |
242 | 241 | $sandbox = $this->configurations['sandbox'] ?? []; |
243 | 242 | |
244 | - if (!($sandbox['enable'] ?? false)) { |
|
243 | + if (!($sandbox['enable'] ?? false)) { |
|
245 | 244 | return ''; |
246 | 245 | } |
247 | 246 | |
@@ -276,7 +275,7 @@ discard block |
||
276 | 275 | { |
277 | 276 | $config = $this->configurations['require-trusted-types-for'] ?? []; |
278 | 277 | |
279 | - if (!($config['script'] ?? false)) { |
|
278 | + if (!($config['script'] ?? false)) { |
|
280 | 279 | return ''; |
281 | 280 | } |
282 | 281 | |
@@ -291,17 +290,17 @@ discard block |
||
291 | 290 | { |
292 | 291 | $trustedTypes = $this->configurations['trusted-types'] ?? []; |
293 | 292 | |
294 | - if (!($trustedTypes['enable'] ?? false)) { |
|
293 | + if (!($trustedTypes['enable'] ?? false)) { |
|
295 | 294 | return ''; |
296 | 295 | } |
297 | 296 | |
298 | 297 | $policies = array_map('trim', $trustedTypes['policies'] ?? []); |
299 | 298 | |
300 | - if ($trustedTypes['default'] ?? false) { |
|
299 | + if ($trustedTypes['default'] ?? false) { |
|
301 | 300 | $policies[] = 'default'; |
302 | 301 | } |
303 | 302 | |
304 | - if ($trustedTypes['allow-duplicates'] ?? false) { |
|
303 | + if ($trustedTypes['allow-duplicates'] ?? false) { |
|
305 | 304 | $policies[] = '\'allow-duplicates\''; |
306 | 305 | } |
307 | 306 | |
@@ -316,7 +315,7 @@ discard block |
||
316 | 315 | */ |
317 | 316 | public function blockAllMixedContent(): string |
318 | 317 | { |
319 | - if (!($this->configurations['block-all-mixed-content'] ?? false)) { |
|
318 | + if (!($this->configurations['block-all-mixed-content'] ?? false)) { |
|
320 | 319 | return ''; |
321 | 320 | } |
322 | 321 | |
@@ -329,7 +328,7 @@ discard block |
||
329 | 328 | */ |
330 | 329 | public function upgradeInsecureRequests(): string |
331 | 330 | { |
332 | - if (!($this->configurations['upgrade-insecure-requests'] ?? false)) { |
|
331 | + if (!($this->configurations['upgrade-insecure-requests'] ?? false)) { |
|
333 | 332 | return ''; |
334 | 333 | } |
335 | 334 | |
@@ -342,7 +341,7 @@ discard block |
||
342 | 341 | */ |
343 | 342 | public function reportTo(): string |
344 | 343 | { |
345 | - if (empty($this->configurations['report-to'])) { |
|
344 | + if (empty($this->configurations['report-to'])) { |
|
346 | 345 | return ''; |
347 | 346 | } |
348 | 347 | |
@@ -355,7 +354,7 @@ discard block |
||
355 | 354 | */ |
356 | 355 | public function reportUri(): string |
357 | 356 | { |
358 | - if (empty($this->configurations['report-uri'])) { |
|
357 | + if (empty($this->configurations['report-uri'])) { |
|
359 | 358 | return ''; |
360 | 359 | } |
361 | 360 | |
@@ -397,14 +396,14 @@ discard block |
||
397 | 396 | protected function directives(): string |
398 | 397 | { |
399 | 398 | $result = []; |
400 | - foreach ($this->configurations as $name => $config) { |
|
401 | - if (!($this->whitelist[$name] ?? false)) { |
|
399 | + foreach ($this->configurations as $name => $config) { |
|
400 | + if (!($this->whitelist[$name] ?? false)) { |
|
402 | 401 | continue; |
403 | 402 | } |
404 | 403 | |
405 | 404 | $value = $this->directive($config); |
406 | 405 | |
407 | - if (empty($value)) { |
|
406 | + if (empty($value)) { |
|
408 | 407 | continue; |
409 | 408 | } |
410 | 409 |