@@ -14,14 +14,14 @@ |
||
14 | 14 | private function &dotGet(array &$data, string $name): mixed |
15 | 15 | { |
16 | 16 | //Generating path relative to a given name and prefix |
17 | - $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name; |
|
18 | - if (empty($path)) { |
|
17 | + $path = (!empty($this->prefix) ? $this->prefix.'.' : '').$name; |
|
18 | + if (empty($path)){ |
|
19 | 19 | return $data; |
20 | 20 | } |
21 | 21 | |
22 | 22 | $path = \explode('.', \rtrim($path, '.')); |
23 | - foreach ($path as $step) { |
|
24 | - if (!\is_array($data) || !\array_key_exists($step, $data)) { |
|
23 | + foreach ($path as $step){ |
|
24 | + if (!\is_array($data) || !\array_key_exists($step, $data)){ |
|
25 | 25 | throw new DotNotFoundException(\sprintf("Unable to find config element '%s'.", $name)); |
26 | 26 | } |
27 | 27 | $data = &$data[$step]; |
@@ -15,13 +15,16 @@ |
||
15 | 15 | { |
16 | 16 | //Generating path relative to a given name and prefix |
17 | 17 | $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name; |
18 | - if (empty($path)) { |
|
18 | + if (empty($path)) |
|
19 | + { |
|
19 | 20 | return $data; |
20 | 21 | } |
21 | 22 | |
22 | 23 | $path = \explode('.', \rtrim($path, '.')); |
23 | - foreach ($path as $step) { |
|
24 | - if (!\is_array($data) || !\array_key_exists($step, $data)) { |
|
24 | + foreach ($path as $step) |
|
25 | + { |
|
26 | + if (!\is_array($data) || !\array_key_exists($step, $data)) |
|
27 | + { |
|
25 | 28 | throw new DotNotFoundException(\sprintf("Unable to find config element '%s'.", $name)); |
26 | 29 | } |
27 | 30 | $data = &$data[$step]; |
@@ -25,15 +25,21 @@ |
||
25 | 25 | |
26 | 26 | public function patch(array $config): array |
27 | 27 | { |
28 | - try { |
|
28 | + try |
|
29 | + { |
|
29 | 30 | $target = &$this->dotGet($config, $this->position); |
30 | 31 | |
31 | - if ($this->key !== null) { |
|
32 | + if ($this->key !== null) |
|
33 | + { |
|
32 | 34 | $target[$this->key] = $this->value; |
33 | - } else { |
|
35 | + } |
|
36 | + else |
|
37 | + { |
|
34 | 38 | $target[] = $this->value; |
35 | 39 | } |
36 | - } catch (DotNotFoundException $e) { |
|
40 | + } |
|
41 | + catch (DotNotFoundException $e) |
|
42 | + { |
|
37 | 43 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
38 | 44 | } |
39 | 45 |
@@ -19,21 +19,21 @@ |
||
19 | 19 | string $position, |
20 | 20 | private ?string $key, |
21 | 21 | private mixed $value, |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | $this->position = $position === '.' ? '' : $position; |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function patch(array $config): array |
27 | 27 | { |
28 | - try { |
|
28 | + try{ |
|
29 | 29 | $target = &$this->dotGet($config, $this->position); |
30 | 30 | |
31 | - if ($this->key !== null) { |
|
31 | + if ($this->key !== null){ |
|
32 | 32 | $target[$this->key] = $this->value; |
33 | - } else { |
|
33 | + }else{ |
|
34 | 34 | $target[] = $this->value; |
35 | 35 | } |
36 | - } catch (DotNotFoundException $e) { |
|
36 | + }catch (DotNotFoundException $e){ |
|
37 | 37 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
38 | 38 | } |
39 | 39 |
@@ -19,9 +19,9 @@ |
||
19 | 19 | */ |
20 | 20 | public function withVerbs(string ...$verbs): RouteInterface |
21 | 21 | { |
22 | - foreach ($verbs as &$verb) { |
|
22 | + foreach ($verbs as &$verb){ |
|
23 | 23 | $verb = \strtoupper($verb); |
24 | - if (!\in_array($verb, RouteInterface::VERBS, true)) { |
|
24 | + if (!\in_array($verb, RouteInterface::VERBS, true)){ |
|
25 | 25 | throw new RouteException(\sprintf('Invalid HTTP verb `%s`', $verb)); |
26 | 26 | } |
27 | 27 |
@@ -19,9 +19,11 @@ |
||
19 | 19 | */ |
20 | 20 | public function withVerbs(string ...$verbs): RouteInterface |
21 | 21 | { |
22 | - foreach ($verbs as &$verb) { |
|
22 | + foreach ($verbs as &$verb) |
|
23 | + { |
|
23 | 24 | $verb = \strtoupper($verb); |
24 | - if (!\in_array($verb, RouteInterface::VERBS, true)) { |
|
25 | + if (!\in_array($verb, RouteInterface::VERBS, true)) |
|
26 | + { |
|
25 | 27 | throw new RouteException(\sprintf('Invalid HTTP verb `%s`', $verb)); |
26 | 28 | } |
27 | 29 |
@@ -27,12 +27,12 @@ |
||
27 | 27 | |
28 | 28 | private function defineValue(?string $sameSite, bool $secure): ?string |
29 | 29 | { |
30 | - if ($sameSite === null) { |
|
30 | + if ($sameSite === null){ |
|
31 | 31 | return null; |
32 | 32 | } |
33 | 33 | |
34 | 34 | $sameSite = \ucfirst(\strtolower($sameSite)); |
35 | - if (!\in_array($sameSite, self::VALUES, true)) { |
|
35 | + if (!\in_array($sameSite, self::VALUES, true)){ |
|
36 | 36 | return null; |
37 | 37 | } |
38 | 38 |
@@ -27,12 +27,14 @@ |
||
27 | 27 | |
28 | 28 | private function defineValue(?string $sameSite, bool $secure): ?string |
29 | 29 | { |
30 | - if ($sameSite === null) { |
|
30 | + if ($sameSite === null) |
|
31 | + { |
|
31 | 32 | return null; |
32 | 33 | } |
33 | 34 | |
34 | 35 | $sameSite = \ucfirst(\strtolower($sameSite)); |
35 | - if (!\in_array($sameSite, self::VALUES, true)) { |
|
36 | + if (!\in_array($sameSite, self::VALUES, true)) |
|
37 | + { |
|
36 | 38 | return null; |
37 | 39 | } |
38 | 40 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | public const LAX = 'Lax'; |
11 | 11 | public const NONE = 'None'; |
12 | 12 | private const VALUES = [self::STRICT, self::LAX, self::NONE]; |
13 | - private const DEFAULT = self::LAX; |
|
13 | + private const default = self::LAX; |
|
14 | 14 | |
15 | 15 | private ?string $sameSite = null; |
16 | 16 | |
@@ -35,6 +35,6 @@ discard block |
||
35 | 35 | return null; |
36 | 36 | } |
37 | 37 | |
38 | - return ($sameSite === self::NONE && !$secure) ? self::DEFAULT : $sameSite; |
|
38 | + return ($sameSite === self::NONE && !$secure) ? self::default : $sameSite; |
|
39 | 39 | } |
40 | 40 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | public function __construct(array $topics = []) |
12 | 12 | { |
13 | - foreach ($topics as $topic => $callback) { |
|
13 | + foreach ($topics as $topic => $callback){ |
|
14 | 14 | $this->register($topic, $callback); |
15 | 15 | } |
16 | 16 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | |
23 | 23 | public function findCallback(string $topic, array &$matches): ?callable |
24 | 24 | { |
25 | - foreach ($this->patterns as $pattern => $callback) { |
|
26 | - if (\preg_match($pattern, $topic, $matches)) { |
|
25 | + foreach ($this->patterns as $pattern => $callback){ |
|
26 | + if (\preg_match($pattern, $topic, $matches)){ |
|
27 | 27 | return $callback; |
28 | 28 | } |
29 | 29 | } |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | private function compilePattern(string $topic): string |
35 | 35 | { |
36 | 36 | $replaces = []; |
37 | - if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
37 | + if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)){ |
|
38 | 38 | $variables = \array_combine($matches[1], $matches[2]); |
39 | - foreach ($variables as $key => $_) { |
|
40 | - $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
|
39 | + foreach ($variables as $key => $_){ |
|
40 | + $replaces['{'.$key.'}'] = '(?P<'.$key.'>[^\/\.]+)'; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | - return '/^' . \strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']) . '$/iu'; |
|
44 | + return '/^'.\strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']).'$/iu'; |
|
45 | 45 | } |
46 | 46 | } |
@@ -10,7 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | public function __construct(array $topics = []) |
12 | 12 | { |
13 | - foreach ($topics as $topic => $callback) { |
|
13 | + foreach ($topics as $topic => $callback) |
|
14 | + { |
|
14 | 15 | $this->register($topic, $callback); |
15 | 16 | } |
16 | 17 | } |
@@ -22,8 +23,10 @@ discard block |
||
22 | 23 | |
23 | 24 | public function findCallback(string $topic, array &$matches): ?callable |
24 | 25 | { |
25 | - foreach ($this->patterns as $pattern => $callback) { |
|
26 | - if (\preg_match($pattern, $topic, $matches)) { |
|
26 | + foreach ($this->patterns as $pattern => $callback) |
|
27 | + { |
|
28 | + if (\preg_match($pattern, $topic, $matches)) |
|
29 | + { |
|
27 | 30 | return $callback; |
28 | 31 | } |
29 | 32 | } |
@@ -34,9 +37,11 @@ discard block |
||
34 | 37 | private function compilePattern(string $topic): string |
35 | 38 | { |
36 | 39 | $replaces = []; |
37 | - if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) { |
|
40 | + if (\preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) |
|
41 | + { |
|
38 | 42 | $variables = \array_combine($matches[1], $matches[2]); |
39 | - foreach ($variables as $key => $_) { |
|
43 | + foreach ($variables as $key => $_) |
|
44 | + { |
|
40 | 45 | $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)'; |
41 | 46 | } |
42 | 47 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | |
9 | 9 | final class NullBroadcast implements BroadcastInterface |
10 | 10 | { |
11 | - public function publish(iterable|string|\Stringable $topics, iterable|string $messages): void |
|
11 | + public function publish(iterable | string | \Stringable $topics, iterable | string $messages): void |
|
12 | 12 | { |
13 | 13 | // Do nothing |
14 | 14 | } |
@@ -26,5 +26,5 @@ |
||
26 | 26 | * @param MessagesList $messages |
27 | 27 | * @throws BroadcastException |
28 | 28 | */ |
29 | - public function publish(iterable|string|\Stringable $topics, iterable|string $messages): void; |
|
29 | + public function publish(iterable | string | \Stringable $topics, iterable | string $messages): void; |
|
30 | 30 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | public function get(array $values): array |
27 | 27 | { |
28 | 28 | $output = []; |
29 | - foreach ($values as $key => $value) { |
|
29 | + foreach ($values as $key => $value){ |
|
30 | 30 | $output[$key] = self::TYPE_DEFAULTS[\gettype($value)] ?? null; |
31 | 31 | } |
32 | 32 |
@@ -26,7 +26,8 @@ |
||
26 | 26 | public function get(array $values): array |
27 | 27 | { |
28 | 28 | $output = []; |
29 | - foreach ($values as $key => $value) { |
|
29 | + foreach ($values as $key => $value) |
|
30 | + { |
|
30 | 31 | $output[$key] = self::TYPE_DEFAULTS[\gettype($value)] ?? null; |
31 | 32 | } |
32 | 33 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public function getAnnotation(mixed $value): string |
28 | 28 | { |
29 | - if (\is_array($value)) { |
|
29 | + if (\is_array($value)){ |
|
30 | 30 | return $this->arrayAnnotationString($value); |
31 | 31 | } |
32 | 32 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | private function arrayAnnotationString(array $value): string |
42 | 42 | { |
43 | 43 | $types = []; |
44 | - foreach ($value as $item) { |
|
44 | + foreach ($value as $item){ |
|
45 | 45 | $types[] = \gettype($item); |
46 | 46 | } |
47 | 47 | $types = \array_unique($types); |
@@ -26,7 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | public function getAnnotation(mixed $value): string |
28 | 28 | { |
29 | - if (\is_array($value)) { |
|
29 | + if (\is_array($value)) |
|
30 | + { |
|
30 | 31 | return $this->arrayAnnotationString($value); |
31 | 32 | } |
32 | 33 | |
@@ -41,7 +42,8 @@ discard block |
||
41 | 42 | private function arrayAnnotationString(array $value): string |
42 | 43 | { |
43 | 44 | $types = []; |
44 | - foreach ($value as $item) { |
|
45 | + foreach ($value as $item) |
|
46 | + { |
|
45 | 47 | $types[] = \gettype($item); |
46 | 48 | } |
47 | 49 | $types = \array_unique($types); |