@@ -25,8 +25,8 @@ |
||
25 | 25 | |
26 | 26 | protected function getFactory(?string $directory = null, bool $strict = true): ConfigManager |
27 | 27 | { |
28 | - if (is_null($directory)) { |
|
29 | - $directory = __DIR__ . '/fixtures'; |
|
28 | + if (is_null($directory)){ |
|
29 | + $directory = __DIR__.'/fixtures'; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | return new ConfigManager( |
@@ -25,7 +25,8 @@ |
||
25 | 25 | |
26 | 26 | protected function getFactory(?string $directory = null, bool $strict = true): ConfigManager |
27 | 27 | { |
28 | - if (is_null($directory)) { |
|
28 | + if (is_null($directory)) |
|
29 | + { |
|
29 | 30 | $directory = __DIR__ . '/fixtures'; |
30 | 31 | } |
31 | 32 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | public function __construct( |
26 | 26 | private readonly LoaderInterface $loader, |
27 | 27 | private readonly bool $strict = true |
28 | - ) { |
|
28 | + ){ |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | |
46 | 46 | public function setDefaults(string $section, array $data): void |
47 | 47 | { |
48 | - if (isset($this->defaults[$section])) { |
|
48 | + if (isset($this->defaults[$section])){ |
|
49 | 49 | throw new ConfiguratorException(\sprintf('Unable to set default config `%s` more than once.', $section)); |
50 | 50 | } |
51 | 51 | |
52 | - if (isset($this->data[$section])) { |
|
52 | + if (isset($this->data[$section])){ |
|
53 | 53 | throw new ConfigDeliveredException( |
54 | 54 | \sprintf('Unable to set default config `%s`, config has been loaded.', $section) |
55 | 55 | ); |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | |
61 | 61 | public function modify(string $section, PatchInterface $patch): array |
62 | 62 | { |
63 | - if (isset($this->instances[$section])) { |
|
64 | - if ($this->strict) { |
|
63 | + if (isset($this->instances[$section])){ |
|
64 | + if ($this->strict){ |
|
65 | 65 | throw new ConfigDeliveredException( |
66 | 66 | \sprintf('Unable to patch config `%s`, config object has already been delivered.', $section) |
67 | 67 | ); |
@@ -72,27 +72,27 @@ discard block |
||
72 | 72 | |
73 | 73 | $data = $this->getConfig($section); |
74 | 74 | |
75 | - try { |
|
75 | + try{ |
|
76 | 76 | return $this->data[$section] = $patch->patch($data); |
77 | - } catch (PatchException $e) { |
|
77 | + }catch (PatchException $e){ |
|
78 | 78 | throw new PatchException(\sprintf('Unable to modify config `%s`.', $section), $e->getCode(), $e); |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | 82 | public function getConfig(?string $section = null): array |
83 | 83 | { |
84 | - if (isset($this->data[$section])) { |
|
84 | + if (isset($this->data[$section])){ |
|
85 | 85 | return $this->data[$section]; |
86 | 86 | } |
87 | 87 | |
88 | - if (isset($this->defaults[$section])) { |
|
88 | + if (isset($this->defaults[$section])){ |
|
89 | 89 | $data = []; |
90 | - if ($this->loader->has($section)) { |
|
90 | + if ($this->loader->has($section)){ |
|
91 | 91 | $data = $this->loader->load($section); |
92 | 92 | } |
93 | 93 | |
94 | 94 | $data = \array_merge($this->defaults[$section], $data); |
95 | - } else { |
|
95 | + }else{ |
|
96 | 96 | $data = $this->loader->load($section); |
97 | 97 | } |
98 | 98 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | public function createInjection(\ReflectionClass $class, ?string $context = null): object |
103 | 103 | { |
104 | 104 | $config = $class->getConstant('CONFIG'); |
105 | - if (isset($this->instances[$config])) { |
|
105 | + if (isset($this->instances[$config])){ |
|
106 | 106 | return $this->instances[$config]; |
107 | 107 | } |
108 | 108 |
@@ -45,11 +45,13 @@ discard block |
||
45 | 45 | |
46 | 46 | public function setDefaults(string $section, array $data): void |
47 | 47 | { |
48 | - if (isset($this->defaults[$section])) { |
|
48 | + if (isset($this->defaults[$section])) |
|
49 | + { |
|
49 | 50 | throw new ConfiguratorException(\sprintf('Unable to set default config `%s` more than once.', $section)); |
50 | 51 | } |
51 | 52 | |
52 | - if (isset($this->data[$section])) { |
|
53 | + if (isset($this->data[$section])) |
|
54 | + { |
|
53 | 55 | throw new ConfigDeliveredException( |
54 | 56 | \sprintf('Unable to set default config `%s`, config has been loaded.', $section) |
55 | 57 | ); |
@@ -60,8 +62,10 @@ discard block |
||
60 | 62 | |
61 | 63 | public function modify(string $section, PatchInterface $patch): array |
62 | 64 | { |
63 | - if (isset($this->instances[$section])) { |
|
64 | - if ($this->strict) { |
|
65 | + if (isset($this->instances[$section])) |
|
66 | + { |
|
67 | + if ($this->strict) |
|
68 | + { |
|
65 | 69 | throw new ConfigDeliveredException( |
66 | 70 | \sprintf('Unable to patch config `%s`, config object has already been delivered.', $section) |
67 | 71 | ); |
@@ -72,27 +76,35 @@ discard block |
||
72 | 76 | |
73 | 77 | $data = $this->getConfig($section); |
74 | 78 | |
75 | - try { |
|
79 | + try |
|
80 | + { |
|
76 | 81 | return $this->data[$section] = $patch->patch($data); |
77 | - } catch (PatchException $e) { |
|
82 | + } |
|
83 | + catch (PatchException $e) |
|
84 | + { |
|
78 | 85 | throw new PatchException(\sprintf('Unable to modify config `%s`.', $section), $e->getCode(), $e); |
79 | 86 | } |
80 | 87 | } |
81 | 88 | |
82 | 89 | public function getConfig(?string $section = null): array |
83 | 90 | { |
84 | - if (isset($this->data[$section])) { |
|
91 | + if (isset($this->data[$section])) |
|
92 | + { |
|
85 | 93 | return $this->data[$section]; |
86 | 94 | } |
87 | 95 | |
88 | - if (isset($this->defaults[$section])) { |
|
96 | + if (isset($this->defaults[$section])) |
|
97 | + { |
|
89 | 98 | $data = []; |
90 | - if ($this->loader->has($section)) { |
|
99 | + if ($this->loader->has($section)) |
|
100 | + { |
|
91 | 101 | $data = $this->loader->load($section); |
92 | 102 | } |
93 | 103 | |
94 | 104 | $data = \array_merge($this->defaults[$section], $data); |
95 | - } else { |
|
105 | + } |
|
106 | + else |
|
107 | + { |
|
96 | 108 | $data = $this->loader->load($section); |
97 | 109 | } |
98 | 110 | |
@@ -102,7 +114,8 @@ discard block |
||
102 | 114 | public function createInjection(\ReflectionClass $class, ?string $context = null): object |
103 | 115 | { |
104 | 116 | $config = $class->getConstant('CONFIG'); |
105 | - if (isset($this->instances[$config])) { |
|
117 | + if (isset($this->instances[$config])) |
|
118 | + { |
|
106 | 119 | return $this->instances[$config]; |
107 | 120 | } |
108 | 121 |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | */ |
30 | 30 | protected function getLogger(?string $channel = null): LoggerInterface |
31 | 31 | { |
32 | - if ($channel !== null) { |
|
32 | + if ($channel !== null){ |
|
33 | 33 | return $this->allocateLogger($channel); |
34 | 34 | } |
35 | 35 | |
36 | - if ($this->logger !== null) { |
|
36 | + if ($this->logger !== null){ |
|
37 | 37 | return $this->logger; |
38 | 38 | } |
39 | 39 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | private function allocateLogger(string $channel): LoggerInterface |
48 | 48 | { |
49 | 49 | $container = ContainerScope::getContainer(); |
50 | - if ($container === null || !$container->has(LogsInterface::class)) { |
|
50 | + if ($container === null || !$container->has(LogsInterface::class)){ |
|
51 | 51 | return $this->logger ?? new NullLogger(); |
52 | 52 | } |
53 | 53 |
@@ -29,11 +29,13 @@ discard block |
||
29 | 29 | */ |
30 | 30 | protected function getLogger(?string $channel = null): LoggerInterface |
31 | 31 | { |
32 | - if ($channel !== null) { |
|
32 | + if ($channel !== null) |
|
33 | + { |
|
33 | 34 | return $this->allocateLogger($channel); |
34 | 35 | } |
35 | 36 | |
36 | - if ($this->logger !== null) { |
|
37 | + if ($this->logger !== null) |
|
38 | + { |
|
37 | 39 | return $this->logger; |
38 | 40 | } |
39 | 41 | |
@@ -47,7 +49,8 @@ discard block |
||
47 | 49 | private function allocateLogger(string $channel): LoggerInterface |
48 | 50 | { |
49 | 51 | $container = ContainerScope::getContainer(); |
50 | - if ($container === null || !$container->has(LogsInterface::class)) { |
|
52 | + if ($container === null || !$container->has(LogsInterface::class)) |
|
53 | + { |
|
51 | 54 | return $this->logger ?? new NullLogger(); |
52 | 55 | } |
53 | 56 |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | { |
14 | 14 | public const INJECTOR = InterfaceLocatorInjector::class; |
15 | 15 | |
16 | - public function getInterfaces(string|null $target = null): array |
|
16 | + public function getInterfaces(string | null $target = null): array |
|
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)){ |
|
19 | 19 | $target = new \ReflectionClass($target); |
20 | 20 | } |
21 | 21 | |
22 | 22 | $result = []; |
23 | - foreach ($this->availableInterfaces() as $interface) { |
|
24 | - try { |
|
23 | + foreach ($this->availableInterfaces() as $interface){ |
|
24 | + try{ |
|
25 | 25 | $reflection = $this->classReflection($interface); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
26 | + }catch (LocatorException $e){ |
|
27 | + if ($this->debug){ |
|
28 | 28 | throw $e; |
29 | 29 | } |
30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | - if (!$this->isTargeted($reflection, $target)) { |
|
35 | + if (!$this->isTargeted($reflection, $target)){ |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $interfaces = []; |
53 | 53 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
54 | + foreach ($this->availableReflections() as $reflection){ |
|
55 | 55 | $interfaces = \array_merge($interfaces, $reflection->getInterfaces()); |
56 | 56 | } |
57 | 57 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool |
65 | 65 | { |
66 | - if (empty($target)) { |
|
66 | + if (empty($target)){ |
|
67 | 67 | return true; |
68 | 68 | } |
69 | 69 |
@@ -15,16 +15,22 @@ discard block |
||
15 | 15 | |
16 | 16 | public function getInterfaces(string|null $target = null): array |
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)) |
|
19 | + { |
|
19 | 20 | $target = new \ReflectionClass($target); |
20 | 21 | } |
21 | 22 | |
22 | 23 | $result = []; |
23 | - foreach ($this->availableInterfaces() as $interface) { |
|
24 | - try { |
|
24 | + foreach ($this->availableInterfaces() as $interface) |
|
25 | + { |
|
26 | + try |
|
27 | + { |
|
25 | 28 | $reflection = $this->classReflection($interface); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
29 | + } |
|
30 | + catch (LocatorException $e) |
|
31 | + { |
|
32 | + if ($this->debug) |
|
33 | + { |
|
28 | 34 | throw $e; |
29 | 35 | } |
30 | 36 | |
@@ -32,7 +38,8 @@ discard block |
||
32 | 38 | continue; |
33 | 39 | } |
34 | 40 | |
35 | - if (!$this->isTargeted($reflection, $target)) { |
|
41 | + if (!$this->isTargeted($reflection, $target)) |
|
42 | + { |
|
36 | 43 | continue; |
37 | 44 | } |
38 | 45 | |
@@ -51,7 +58,8 @@ discard block |
||
51 | 58 | { |
52 | 59 | $interfaces = []; |
53 | 60 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
61 | + foreach ($this->availableReflections() as $reflection) |
|
62 | + { |
|
55 | 63 | $interfaces = \array_merge($interfaces, $reflection->getInterfaces()); |
56 | 64 | } |
57 | 65 | |
@@ -63,7 +71,8 @@ discard block |
||
63 | 71 | */ |
64 | 72 | protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool |
65 | 73 | { |
66 | - if (empty($target)) { |
|
74 | + if (empty($target)) |
|
75 | + { |
|
67 | 76 | return true; |
68 | 77 | } |
69 | 78 |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | { |
14 | 14 | public const INJECTOR = EnumLocatorInjector::class; |
15 | 15 | |
16 | - public function getEnums(object|string|null $target = null): array |
|
16 | + public function getEnums(object | string | null $target = null): array |
|
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)){ |
|
19 | 19 | $target = new \ReflectionClass($target); |
20 | 20 | } |
21 | 21 | |
22 | 22 | $result = []; |
23 | - foreach ($this->availableEnums() as $enum) { |
|
24 | - try { |
|
23 | + foreach ($this->availableEnums() as $enum){ |
|
24 | + try{ |
|
25 | 25 | $reflection = $this->enumReflection($enum); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
26 | + }catch (LocatorException $e){ |
|
27 | + if ($this->debug){ |
|
28 | 28 | throw $e; |
29 | 29 | } |
30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
35 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()){ |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $enums = []; |
53 | 53 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
54 | + foreach ($this->availableReflections() as $reflection){ |
|
55 | 55 | $enums = \array_merge($enums, $reflection->getEnums()); |
56 | 56 | } |
57 | 57 | |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function isTargeted(\ReflectionEnum $enum, ?\ReflectionClass $target = null): bool |
65 | 65 | { |
66 | - if ($target === null) { |
|
66 | + if ($target === null){ |
|
67 | 67 | return true; |
68 | 68 | } |
69 | 69 | |
70 | - if (!$target->isTrait()) { |
|
70 | + if (!$target->isTrait()){ |
|
71 | 71 | //Target is interface or class |
72 | 72 | /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */ |
73 | 73 | return $enum->isSubclassOf($target) || $enum->getName() === $target->getName(); |
@@ -15,16 +15,22 @@ discard block |
||
15 | 15 | |
16 | 16 | public function getEnums(object|string|null $target = null): array |
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)) |
|
19 | + { |
|
19 | 20 | $target = new \ReflectionClass($target); |
20 | 21 | } |
21 | 22 | |
22 | 23 | $result = []; |
23 | - foreach ($this->availableEnums() as $enum) { |
|
24 | - try { |
|
24 | + foreach ($this->availableEnums() as $enum) |
|
25 | + { |
|
26 | + try |
|
27 | + { |
|
25 | 28 | $reflection = $this->enumReflection($enum); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
29 | + } |
|
30 | + catch (LocatorException $e) |
|
31 | + { |
|
32 | + if ($this->debug) |
|
33 | + { |
|
28 | 34 | throw $e; |
29 | 35 | } |
30 | 36 | |
@@ -32,7 +38,8 @@ discard block |
||
32 | 38 | continue; |
33 | 39 | } |
34 | 40 | |
35 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
41 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) |
|
42 | + { |
|
36 | 43 | continue; |
37 | 44 | } |
38 | 45 | |
@@ -51,7 +58,8 @@ discard block |
||
51 | 58 | { |
52 | 59 | $enums = []; |
53 | 60 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
61 | + foreach ($this->availableReflections() as $reflection) |
|
62 | + { |
|
55 | 63 | $enums = \array_merge($enums, $reflection->getEnums()); |
56 | 64 | } |
57 | 65 | |
@@ -63,11 +71,13 @@ discard block |
||
63 | 71 | */ |
64 | 72 | protected function isTargeted(\ReflectionEnum $enum, ?\ReflectionClass $target = null): bool |
65 | 73 | { |
66 | - if ($target === null) { |
|
74 | + if ($target === null) |
|
75 | + { |
|
67 | 76 | return true; |
68 | 77 | } |
69 | 78 | |
70 | - if (!$target->isTrait()) { |
|
79 | + if (!$target->isTrait()) |
|
80 | + { |
|
71 | 81 | //Target is interface or class |
72 | 82 | /** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/9489 */ |
73 | 83 | return $enum->isSubclassOf($target) || $enum->getName() === $target->getName(); |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | { |
14 | 14 | public const INJECTOR = ClassLocatorInjector::class; |
15 | 15 | |
16 | - public function getClasses(object|string|null $target = null): array |
|
16 | + public function getClasses(object | string | null $target = null): array |
|
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)){ |
|
19 | 19 | $target = new \ReflectionClass($target); |
20 | 20 | } |
21 | 21 | |
22 | 22 | $result = []; |
23 | - foreach ($this->availableClasses() as $class) { |
|
24 | - try { |
|
23 | + foreach ($this->availableClasses() as $class){ |
|
24 | + try{ |
|
25 | 25 | $reflection = $this->classReflection($class); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
26 | + }catch (LocatorException $e){ |
|
27 | + if ($this->debug){ |
|
28 | 28 | throw $e; |
29 | 29 | } |
30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
35 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()){ |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $classes = []; |
53 | 53 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
54 | + foreach ($this->availableReflections() as $reflection){ |
|
55 | 55 | $classes = \array_merge($classes, $reflection->getClasses()); |
56 | 56 | } |
57 | 57 | |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool |
65 | 65 | { |
66 | - if (empty($target)) { |
|
66 | + if (empty($target)){ |
|
67 | 67 | return true; |
68 | 68 | } |
69 | 69 | |
70 | - if (!$target->isTrait()) { |
|
70 | + if (!$target->isTrait()){ |
|
71 | 71 | //Target is interface or class |
72 | 72 | return $class->isSubclassOf($target) || $class->getName() === $target->getName(); |
73 | 73 | } |
@@ -15,16 +15,22 @@ discard block |
||
15 | 15 | |
16 | 16 | public function getClasses(object|string|null $target = null): array |
17 | 17 | { |
18 | - if (!empty($target)) { |
|
18 | + if (!empty($target)) |
|
19 | + { |
|
19 | 20 | $target = new \ReflectionClass($target); |
20 | 21 | } |
21 | 22 | |
22 | 23 | $result = []; |
23 | - foreach ($this->availableClasses() as $class) { |
|
24 | - try { |
|
24 | + foreach ($this->availableClasses() as $class) |
|
25 | + { |
|
26 | + try |
|
27 | + { |
|
25 | 28 | $reflection = $this->classReflection($class); |
26 | - } catch (LocatorException $e) { |
|
27 | - if ($this->debug) { |
|
29 | + } |
|
30 | + catch (LocatorException $e) |
|
31 | + { |
|
32 | + if ($this->debug) |
|
33 | + { |
|
28 | 34 | throw $e; |
29 | 35 | } |
30 | 36 | |
@@ -32,7 +38,8 @@ discard block |
||
32 | 38 | continue; |
33 | 39 | } |
34 | 40 | |
35 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
41 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) |
|
42 | + { |
|
36 | 43 | continue; |
37 | 44 | } |
38 | 45 | |
@@ -51,7 +58,8 @@ discard block |
||
51 | 58 | { |
52 | 59 | $classes = []; |
53 | 60 | |
54 | - foreach ($this->availableReflections() as $reflection) { |
|
61 | + foreach ($this->availableReflections() as $reflection) |
|
62 | + { |
|
55 | 63 | $classes = \array_merge($classes, $reflection->getClasses()); |
56 | 64 | } |
57 | 65 | |
@@ -63,11 +71,13 @@ discard block |
||
63 | 71 | */ |
64 | 72 | protected function isTargeted(\ReflectionClass $class, ?\ReflectionClass $target = null): bool |
65 | 73 | { |
66 | - if (empty($target)) { |
|
74 | + if (empty($target)) |
|
75 | + { |
|
67 | 76 | return true; |
68 | 77 | } |
69 | 78 | |
70 | - if (!$target->isTrait()) { |
|
79 | + if (!$target->isTrait()) |
|
80 | + { |
|
71 | 81 | //Target is interface or class |
72 | 82 | return $class->isSubclassOf($target) || $class->getName() === $target->getName(); |
73 | 83 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | private readonly bool $secure = false, |
23 | 23 | private readonly bool $httpOnly = true, |
24 | 24 | private readonly ?string $sameSite = null |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function fetchToken(Request $request): ?string |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ): Response { |
40 | 40 | /** @var CookieQueue $cookieQueue */ |
41 | 41 | $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE); |
42 | - if ($cookieQueue === null) { |
|
42 | + if ($cookieQueue === null){ |
|
43 | 43 | return $response->withAddedHeader( |
44 | 44 | 'Set-Cookie', |
45 | 45 | Cookie::create( |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | ); |
56 | 56 | } |
57 | 57 | |
58 | - if ($tokenID === null) { |
|
58 | + if ($tokenID === null){ |
|
59 | 59 | $cookieQueue->delete($this->cookie); |
60 | - } else { |
|
60 | + }else{ |
|
61 | 61 | $cookieQueue->set( |
62 | 62 | $this->cookie, |
63 | 63 | $tokenID, |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | private function getLifetime(?\DateTimeInterface $expiresAt = null): ?int |
86 | 86 | { |
87 | - if ($expiresAt === null) { |
|
87 | + if ($expiresAt === null){ |
|
88 | 88 | return null; |
89 | 89 | } |
90 | 90 |
@@ -39,7 +39,8 @@ discard block |
||
39 | 39 | ): Response { |
40 | 40 | /** @var CookieQueue $cookieQueue */ |
41 | 41 | $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE); |
42 | - if ($cookieQueue === null) { |
|
42 | + if ($cookieQueue === null) |
|
43 | + { |
|
43 | 44 | return $response->withAddedHeader( |
44 | 45 | 'Set-Cookie', |
45 | 46 | Cookie::create( |
@@ -55,9 +56,12 @@ discard block |
||
55 | 56 | ); |
56 | 57 | } |
57 | 58 | |
58 | - if ($tokenID === null) { |
|
59 | + if ($tokenID === null) |
|
60 | + { |
|
59 | 61 | $cookieQueue->delete($this->cookie); |
60 | - } else { |
|
62 | + } |
|
63 | + else |
|
64 | + { |
|
61 | 65 | $cookieQueue->set( |
62 | 66 | $this->cookie, |
63 | 67 | $tokenID, |
@@ -84,7 +88,8 @@ discard block |
||
84 | 88 | */ |
85 | 89 | private function getLifetime(?\DateTimeInterface $expiresAt = null): ?int |
86 | 90 | { |
87 | - if ($expiresAt === null) { |
|
91 | + if ($expiresAt === null) |
|
92 | + { |
|
88 | 93 | return null; |
89 | 94 | } |
90 | 95 |
@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | public function __construct( |
17 | 17 | private readonly string $header = 'X-Auth-Token', |
18 | 18 | private readonly string $valueFormat = '%s' |
19 | - ) { |
|
19 | + ){ |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function fetchToken(Request $request): ?string |
23 | 23 | { |
24 | - if ($request->hasHeader($this->header)) { |
|
24 | + if ($request->hasHeader($this->header)){ |
|
25 | 25 | return $this->extractToken($request); |
26 | 26 | } |
27 | 27 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | string $tokenID, |
35 | 35 | ?\DateTimeInterface $expiresAt = null |
36 | 36 | ): Response { |
37 | - if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) { |
|
37 | + if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID){ |
|
38 | 38 | return $response; |
39 | 39 | } |
40 | 40 | |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | { |
51 | 51 | $headerLine = $request->getHeaderLine($this->header); |
52 | 52 | |
53 | - if ($this->valueFormat !== '%s') { |
|
53 | + if ($this->valueFormat !== '%s'){ |
|
54 | 54 | [$token] = sscanf($headerLine, $this->valueFormat); |
55 | 55 | |
56 | - return $token !== null ? (string) $token : null; |
|
56 | + return $token !== null ? (string)$token : null; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return $headerLine; |
@@ -21,7 +21,8 @@ discard block |
||
21 | 21 | |
22 | 22 | public function fetchToken(Request $request): ?string |
23 | 23 | { |
24 | - if ($request->hasHeader($this->header)) { |
|
24 | + if ($request->hasHeader($this->header)) |
|
25 | + { |
|
25 | 26 | return $this->extractToken($request); |
26 | 27 | } |
27 | 28 | |
@@ -34,7 +35,8 @@ discard block |
||
34 | 35 | string $tokenID, |
35 | 36 | ?\DateTimeInterface $expiresAt = null |
36 | 37 | ): Response { |
37 | - if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) { |
|
38 | + if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) |
|
39 | + { |
|
38 | 40 | return $response; |
39 | 41 | } |
40 | 42 | |
@@ -50,7 +52,8 @@ discard block |
||
50 | 52 | { |
51 | 53 | $headerLine = $request->getHeaderLine($this->header); |
52 | 54 | |
53 | - if ($this->valueFormat !== '%s') { |
|
55 | + if ($this->valueFormat !== '%s') |
|
56 | + { |
|
54 | 57 | [$token] = sscanf($headerLine, $this->valueFormat); |
55 | 58 | |
56 | 59 | return $token !== null ? (string) $token : null; |
@@ -9,8 +9,8 @@ |
||
9 | 9 | public function __construct(?\Throwable $previous = null, ?string $message = null) |
10 | 10 | { |
11 | 11 | parent::__construct( |
12 | - message: $message ?? 'Unable to set value. The given data was invalid.', |
|
13 | - previous: $previous, |
|
12 | + message : $message ?? 'Unable to set value. The given data was invalid.', |
|
13 | + previous : $previous, |
|
14 | 14 | ); |
15 | 15 | } |
16 | 16 | } |