@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | private readonly InvokerInterface $invoker, |
| 24 | 24 | private readonly ResolverInterface $resolver, |
| 25 | 25 | private readonly Initializer $initializer |
| 26 | - ) { |
|
| 26 | + ){ |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function getClasses(): array |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $bootloaders = \iterator_to_array($this->initializer->init($classes)); |
| 54 | 54 | |
| 55 | - foreach ($bootloaders as $data) { |
|
| 55 | + foreach ($bootloaders as $data){ |
|
| 56 | 56 | $this->invokeBootloader($data['bootloader'], Methods::INIT, $data['options']); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $this->fireCallbacks($bootingCallbacks); |
| 60 | 60 | |
| 61 | - foreach ($bootloaders as $data) { |
|
| 61 | + foreach ($bootloaders as $data){ |
|
| 62 | 62 | $this->invokeBootloader($data['bootloader'], Methods::BOOT, $data['options']); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | private function invokeBootloader(BootloaderInterface $bootloader, Methods $method, array $options): void |
| 69 | 69 | { |
| 70 | 70 | $refl = new \ReflectionClass($bootloader); |
| 71 | - if (!$refl->hasMethod($method->value)) { |
|
| 71 | + if (!$refl->hasMethod($method->value)){ |
|
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $method = $refl->getMethod($method->value); |
| 76 | 76 | |
| 77 | 77 | $args = $this->resolver->resolveArguments($method); |
| 78 | - if (!isset($args['boot'])) { |
|
| 78 | + if (!isset($args['boot'])){ |
|
| 79 | 79 | $args['boot'] = $options; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | private function fireCallbacks(array $callbacks): void |
| 89 | 89 | { |
| 90 | - foreach ($callbacks as $callback) { |
|
| 90 | + foreach ($callbacks as $callback){ |
|
| 91 | 91 | $this->invoker->invoke($callback); |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -52,13 +52,15 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $bootloaders = \iterator_to_array($this->initializer->init($classes)); |
| 54 | 54 | |
| 55 | - foreach ($bootloaders as $data) { |
|
| 55 | + foreach ($bootloaders as $data) |
|
| 56 | + { |
|
| 56 | 57 | $this->invokeBootloader($data['bootloader'], Methods::INIT, $data['options']); |
| 57 | 58 | } |
| 58 | 59 | |
| 59 | 60 | $this->fireCallbacks($bootingCallbacks); |
| 60 | 61 | |
| 61 | - foreach ($bootloaders as $data) { |
|
| 62 | + foreach ($bootloaders as $data) |
|
| 63 | + { |
|
| 62 | 64 | $this->invokeBootloader($data['bootloader'], Methods::BOOT, $data['options']); |
| 63 | 65 | } |
| 64 | 66 | |
@@ -68,14 +70,16 @@ discard block |
||
| 68 | 70 | private function invokeBootloader(BootloaderInterface $bootloader, Methods $method, array $options): void |
| 69 | 71 | { |
| 70 | 72 | $refl = new \ReflectionClass($bootloader); |
| 71 | - if (!$refl->hasMethod($method->value)) { |
|
| 73 | + if (!$refl->hasMethod($method->value)) |
|
| 74 | + { |
|
| 72 | 75 | return; |
| 73 | 76 | } |
| 74 | 77 | |
| 75 | 78 | $method = $refl->getMethod($method->value); |
| 76 | 79 | |
| 77 | 80 | $args = $this->resolver->resolveArguments($method); |
| 78 | - if (!isset($args['boot'])) { |
|
| 81 | + if (!isset($args['boot'])) |
|
| 82 | + { |
|
| 79 | 83 | $args['boot'] = $options; |
| 80 | 84 | } |
| 81 | 85 | |
@@ -87,7 +91,8 @@ discard block |
||
| 87 | 91 | */ |
| 88 | 92 | private function fireCallbacks(array $callbacks): void |
| 89 | 93 | { |
| 90 | - foreach ($callbacks as $callback) { |
|
| 94 | + foreach ($callbacks as $callback) |
|
| 95 | + { |
|
| 91 | 96 | $this->invoker->invoke($callback); |
| 92 | 97 | } |
| 93 | 98 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function register(string $class): void |
| 24 | 24 | { |
| 25 | - if ($this->isBooted($class)) { |
|
| 25 | + if ($this->isBooted($class)){ |
|
| 26 | 26 | throw new BootloaderAlreadyBootedException($class); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -22,7 +22,8 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function register(string $class): void |
| 24 | 24 | { |
| 25 | - if ($this->isBooted($class)) { |
|
| 25 | + if ($this->isBooted($class)) |
|
| 26 | + { |
|
| 26 | 27 | throw new BootloaderAlreadyBootedException($class); |
| 27 | 28 | } |
| 28 | 29 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | private readonly ContainerInterface $container, |
| 24 | 24 | private readonly BinderInterface $binder, |
| 25 | 25 | private readonly ClassesRegistry $bootloaders = new ClassesRegistry() |
| 26 | - ) { |
|
| 26 | + ){ |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -33,23 +33,23 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function init(array $classes): \Generator |
| 35 | 35 | { |
| 36 | - foreach ($classes as $class => $options) { |
|
| 36 | + foreach ($classes as $class => $options){ |
|
| 37 | 37 | // default bootload syntax as simple array |
| 38 | - if (\is_string($options)) { |
|
| 38 | + if (\is_string($options)){ |
|
| 39 | 39 | $class = $options; |
| 40 | 40 | $options = []; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Replace class aliases with source classes |
| 44 | - try { |
|
| 44 | + try{ |
|
| 45 | 45 | $ref = (new \ReflectionClass($class)); |
| 46 | - } catch (\ReflectionException) { |
|
| 46 | + }catch (\ReflectionException){ |
|
| 47 | 47 | throw new ClassNotFoundException( |
| 48 | 48 | \sprintf('Bootloader class `%s` is not exist.', $class) |
| 49 | 49 | ); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if ($this->bootloaders->isBooted($class) || $ref->isAbstract()) { |
|
| 52 | + if ($this->bootloaders->isBooted($class) || $ref->isAbstract()){ |
|
| 53 | 53 | continue; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $this->bootloaders->register($class); |
| 58 | 58 | $bootloader = $this->container->get($class); |
| 59 | 59 | |
| 60 | - if (!$this->isBootloader($bootloader)) { |
|
| 60 | + if (!$this->isBootloader($bootloader)){ |
|
| 61 | 61 | continue; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | private function initBootloader(BootloaderInterface $bootloader): iterable |
| 79 | 79 | { |
| 80 | - if ($bootloader instanceof DependedInterface) { |
|
| 80 | + if ($bootloader instanceof DependedInterface){ |
|
| 81 | 81 | yield from $this->init($this->getDependencies($bootloader)); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | private function initBindings(array $bindings, array $singletons): void |
| 97 | 97 | { |
| 98 | - foreach ($bindings as $aliases => $resolver) { |
|
| 98 | + foreach ($bindings as $aliases => $resolver){ |
|
| 99 | 99 | $this->binder->bind($aliases, $resolver); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - foreach ($singletons as $aliases => $resolver) { |
|
| 102 | + foreach ($singletons as $aliases => $resolver){ |
|
| 103 | 103 | $this->binder->bindSingleton($aliases, $resolver); |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | $methodsDeps = []; |
| 114 | 114 | |
| 115 | - foreach (Methods::cases() as $method) { |
|
| 116 | - if ($reflectionClass->hasMethod($method->value)) { |
|
| 115 | + foreach (Methods::cases() as $method){ |
|
| 116 | + if ($reflectionClass->hasMethod($method->value)){ |
|
| 117 | 117 | $methodsDeps[] = $this->findBootloaderClassesInMethod( |
| 118 | 118 | $reflectionClass->getMethod($method->value) |
| 119 | 119 | ); |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | private function findBootloaderClassesInMethod(\ReflectionMethod $method): array |
| 127 | 127 | { |
| 128 | 128 | $args = []; |
| 129 | - foreach ($method->getParameters() as $parameter) { |
|
| 129 | + foreach ($method->getParameters() as $parameter){ |
|
| 130 | 130 | $type = $parameter->getType(); |
| 131 | - if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)) { |
|
| 131 | + if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)){ |
|
| 132 | 132 | $args[] = $type->getName(); |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @psalm-pure |
| 151 | 151 | * @psalm-assert-if-true TClass $class |
| 152 | 152 | */ |
| 153 | - private function isBootloader(string|object $class): bool |
|
| 153 | + private function isBootloader(string | object $class): bool |
|
| 154 | 154 | { |
| 155 | 155 | return \is_subclass_of($class, BootloaderInterface::class); |
| 156 | 156 | } |
@@ -33,23 +33,29 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function init(array $classes): \Generator |
| 35 | 35 | { |
| 36 | - foreach ($classes as $class => $options) { |
|
| 36 | + foreach ($classes as $class => $options) |
|
| 37 | + { |
|
| 37 | 38 | // default bootload syntax as simple array |
| 38 | - if (\is_string($options)) { |
|
| 39 | + if (\is_string($options)) |
|
| 40 | + { |
|
| 39 | 41 | $class = $options; |
| 40 | 42 | $options = []; |
| 41 | 43 | } |
| 42 | 44 | |
| 43 | 45 | // Replace class aliases with source classes |
| 44 | - try { |
|
| 46 | + try |
|
| 47 | + { |
|
| 45 | 48 | $ref = (new \ReflectionClass($class)); |
| 46 | - } catch (\ReflectionException) { |
|
| 49 | + } |
|
| 50 | + catch (\ReflectionException) |
|
| 51 | + { |
|
| 47 | 52 | throw new ClassNotFoundException( |
| 48 | 53 | \sprintf('Bootloader class `%s` is not exist.', $class) |
| 49 | 54 | ); |
| 50 | 55 | } |
| 51 | 56 | |
| 52 | - if ($this->bootloaders->isBooted($class) || $ref->isAbstract()) { |
|
| 57 | + if ($this->bootloaders->isBooted($class) || $ref->isAbstract()) |
|
| 58 | + { |
|
| 53 | 59 | continue; |
| 54 | 60 | } |
| 55 | 61 | |
@@ -57,7 +63,8 @@ discard block |
||
| 57 | 63 | $this->bootloaders->register($class); |
| 58 | 64 | $bootloader = $this->container->get($class); |
| 59 | 65 | |
| 60 | - if (!$this->isBootloader($bootloader)) { |
|
| 66 | + if (!$this->isBootloader($bootloader)) |
|
| 67 | + { |
|
| 61 | 68 | continue; |
| 62 | 69 | } |
| 63 | 70 | |
@@ -77,7 +84,8 @@ discard block |
||
| 77 | 84 | */ |
| 78 | 85 | private function initBootloader(BootloaderInterface $bootloader): iterable |
| 79 | 86 | { |
| 80 | - if ($bootloader instanceof DependedInterface) { |
|
| 87 | + if ($bootloader instanceof DependedInterface) |
|
| 88 | + { |
|
| 81 | 89 | yield from $this->init($this->getDependencies($bootloader)); |
| 82 | 90 | } |
| 83 | 91 | |
@@ -95,11 +103,13 @@ discard block |
||
| 95 | 103 | */ |
| 96 | 104 | private function initBindings(array $bindings, array $singletons): void |
| 97 | 105 | { |
| 98 | - foreach ($bindings as $aliases => $resolver) { |
|
| 106 | + foreach ($bindings as $aliases => $resolver) |
|
| 107 | + { |
|
| 99 | 108 | $this->binder->bind($aliases, $resolver); |
| 100 | 109 | } |
| 101 | 110 | |
| 102 | - foreach ($singletons as $aliases => $resolver) { |
|
| 111 | + foreach ($singletons as $aliases => $resolver) |
|
| 112 | + { |
|
| 103 | 113 | $this->binder->bindSingleton($aliases, $resolver); |
| 104 | 114 | } |
| 105 | 115 | } |
@@ -112,8 +122,10 @@ discard block |
||
| 112 | 122 | |
| 113 | 123 | $methodsDeps = []; |
| 114 | 124 | |
| 115 | - foreach (Methods::cases() as $method) { |
|
| 116 | - if ($reflectionClass->hasMethod($method->value)) { |
|
| 125 | + foreach (Methods::cases() as $method) |
|
| 126 | + { |
|
| 127 | + if ($reflectionClass->hasMethod($method->value)) |
|
| 128 | + { |
|
| 117 | 129 | $methodsDeps[] = $this->findBootloaderClassesInMethod( |
| 118 | 130 | $reflectionClass->getMethod($method->value) |
| 119 | 131 | ); |
@@ -126,9 +138,11 @@ discard block |
||
| 126 | 138 | private function findBootloaderClassesInMethod(\ReflectionMethod $method): array |
| 127 | 139 | { |
| 128 | 140 | $args = []; |
| 129 | - foreach ($method->getParameters() as $parameter) { |
|
| 141 | + foreach ($method->getParameters() as $parameter) |
|
| 142 | + { |
|
| 130 | 143 | $type = $parameter->getType(); |
| 131 | - if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)) { |
|
| 144 | + if ($type instanceof \ReflectionNamedType && $this->shouldBeBooted($type)) |
|
| 145 | + { |
|
| 132 | 146 | $args[] = $type->getName(); |
| 133 | 147 | } |
| 134 | 148 | } |
@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | { |
| 14 | 14 | public function __construct( |
| 15 | 15 | private array $directories = [] |
| 16 | - ) { |
|
| 17 | - foreach ($directories as $name => $directory) { |
|
| 16 | + ){ |
|
| 17 | + foreach ($directories as $name => $directory){ |
|
| 18 | 18 | $this->set($name, $directory); |
| 19 | 19 | } |
| 20 | 20 | } |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | public function set(string $name, string $path): DirectoriesInterface |
| 28 | 28 | { |
| 29 | 29 | $path = \str_replace(['\\', '//'], '/', $path); |
| 30 | - $this->directories[$name] = \rtrim($path, '/') . '/'; |
|
| 30 | + $this->directories[$name] = \rtrim($path, '/').'/'; |
|
| 31 | 31 | |
| 32 | 32 | return $this; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function get(string $name): string |
| 36 | 36 | { |
| 37 | - if (!$this->has($name)) { |
|
| 37 | + if (!$this->has($name)){ |
|
| 38 | 38 | throw new DirectoryException("Undefined directory '{$name}'"); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -14,7 +14,8 @@ discard block |
||
| 14 | 14 | public function __construct( |
| 15 | 15 | private array $directories = [] |
| 16 | 16 | ) { |
| 17 | - foreach ($directories as $name => $directory) { |
|
| 17 | + foreach ($directories as $name => $directory) |
|
| 18 | + { |
|
| 18 | 19 | $this->set($name, $directory); |
| 19 | 20 | } |
| 20 | 21 | } |
@@ -34,7 +35,8 @@ discard block |
||
| 34 | 35 | |
| 35 | 36 | public function get(string $name): string |
| 36 | 37 | { |
| 37 | - if (!$this->has($name)) { |
|
| 38 | + if (!$this->has($name)) |
|
| 39 | + { |
|
| 38 | 40 | throw new DirectoryException("Undefined directory '{$name}'"); |
| 39 | 41 | } |
| 40 | 42 | |
@@ -13,6 +13,6 @@ |
||
| 13 | 13 | { |
| 14 | 14 | public function __construct( |
| 15 | 15 | public readonly FinalizerInterface $finalizer |
| 16 | - ) { |
|
| 16 | + ){ |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -14,6 +14,6 @@ |
||
| 14 | 14 | { |
| 15 | 15 | public function __construct( |
| 16 | 16 | public readonly DispatcherInterface $dispatcher |
| 17 | - ) { |
|
| 17 | + ){ |
|
| 18 | 18 | } |
| 19 | 19 | } |
@@ -13,6 +13,6 @@ |
||
| 13 | 13 | { |
| 14 | 14 | public function __construct( |
| 15 | 15 | public readonly KernelInterface $kernel |
| 16 | - ) { |
|
| 16 | + ){ |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | use Spiral\Core\ContainerScope; |
| 10 | 10 | use Spiral\Core\Exception\ScopeException; |
| 11 | 11 | |
| 12 | -if (!function_exists('spiral')) { |
|
| 12 | +if (!function_exists('spiral')){ |
|
| 13 | 13 | /** |
| 14 | 14 | * Resolve given alias in current IoC scope. |
| 15 | 15 | * |
@@ -22,19 +22,19 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | function spiral(string $alias): mixed |
| 24 | 24 | { |
| 25 | - if (ContainerScope::getContainer() === null) { |
|
| 25 | + if (ContainerScope::getContainer() === null){ |
|
| 26 | 26 | throw new ScopeException('Container scope was not set.'); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - try { |
|
| 29 | + try{ |
|
| 30 | 30 | return ContainerScope::getContainer()->get($alias); |
| 31 | - } catch (ContainerExceptionInterface $e) { |
|
| 31 | + }catch (ContainerExceptionInterface $e){ |
|
| 32 | 32 | throw new ScopeException($e->getMessage(), $e->getCode(), $e); |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | -if (!function_exists('directory')) { |
|
| 37 | +if (!function_exists('directory')){ |
|
| 38 | 38 | /** |
| 39 | 39 | * Get directory alias value. Uses application core from the current global scope. |
| 40 | 40 | * |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -if (!function_exists('env')) { |
|
| 53 | +if (!function_exists('env')){ |
|
| 54 | 54 | /** |
| 55 | 55 | * Gets the value of an environment variable. Uses application core from the current global scope. |
| 56 | 56 | * |
@@ -9,7 +9,8 @@ discard block |
||
| 9 | 9 | use Spiral\Core\ContainerScope; |
| 10 | 10 | use Spiral\Core\Exception\ScopeException; |
| 11 | 11 | |
| 12 | -if (!function_exists('spiral')) { |
|
| 12 | +if (!function_exists('spiral')) |
|
| 13 | +{ |
|
| 13 | 14 | /** |
| 14 | 15 | * Resolve given alias in current IoC scope. |
| 15 | 16 | * |
@@ -22,19 +23,24 @@ discard block |
||
| 22 | 23 | */ |
| 23 | 24 | function spiral(string $alias): mixed |
| 24 | 25 | { |
| 25 | - if (ContainerScope::getContainer() === null) { |
|
| 26 | + if (ContainerScope::getContainer() === null) |
|
| 27 | + { |
|
| 26 | 28 | throw new ScopeException('Container scope was not set.'); |
| 27 | 29 | } |
| 28 | 30 | |
| 29 | - try { |
|
| 31 | + try |
|
| 32 | + { |
|
| 30 | 33 | return ContainerScope::getContainer()->get($alias); |
| 31 | - } catch (ContainerExceptionInterface $e) { |
|
| 34 | + } |
|
| 35 | + catch (ContainerExceptionInterface $e) |
|
| 36 | + { |
|
| 32 | 37 | throw new ScopeException($e->getMessage(), $e->getCode(), $e); |
| 33 | 38 | } |
| 34 | 39 | } |
| 35 | 40 | } |
| 36 | 41 | |
| 37 | -if (!function_exists('directory')) { |
|
| 42 | +if (!function_exists('directory')) |
|
| 43 | +{ |
|
| 38 | 44 | /** |
| 39 | 45 | * Get directory alias value. Uses application core from the current global scope. |
| 40 | 46 | * |
@@ -50,7 +56,8 @@ discard block |
||
| 50 | 56 | } |
| 51 | 57 | } |
| 52 | 58 | |
| 53 | -if (!function_exists('env')) { |
|
| 59 | +if (!function_exists('env')) |
|
| 60 | +{ |
|
| 54 | 61 | /** |
| 55 | 62 | * Gets the value of an environment variable. Uses application core from the current global scope. |
| 56 | 63 | * |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | public function __construct( |
| 26 | 26 | array $values = [], |
| 27 | 27 | private bool $overwrite = false |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | $this->values = $values + $_ENV + $_SERVER; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function getID(): string |
| 33 | 33 | { |
| 34 | - if (empty($this->id)) { |
|
| 34 | + if (empty($this->id)){ |
|
| 35 | 35 | $this->id = \md5(\serialize($this->values)); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | public function set(string $name, mixed $value): self |
| 42 | 42 | { |
| 43 | - if (\array_key_exists($name, $this->values) && !$this->overwrite) { |
|
| 43 | + if (\array_key_exists($name, $this->values) && !$this->overwrite){ |
|
| 44 | 44 | return $this; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | public function get(string $name, mixed $default = null): mixed |
| 56 | 56 | { |
| 57 | - if (isset($this->values[$name])) { |
|
| 57 | + if (isset($this->values[$name])){ |
|
| 58 | 58 | return $this->normalize($this->values[$name]); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $result = []; |
| 70 | 70 | |
| 71 | - foreach ($this->values as $key => $value) { |
|
| 71 | + foreach ($this->values as $key => $value){ |
|
| 72 | 72 | $result[$key] = $this->normalize($value); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -77,12 +77,12 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | protected function normalize(mixed $value): mixed |
| 79 | 79 | { |
| 80 | - if (!\is_string($value)) { |
|
| 80 | + if (!\is_string($value)){ |
|
| 81 | 81 | return $value; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $alias = \strtolower($value); |
| 85 | - if (isset(self::VALUE_MAP[$alias])) { |
|
| 85 | + if (isset(self::VALUE_MAP[$alias])){ |
|
| 86 | 86 | return self::VALUE_MAP[$alias]; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -31,7 +31,8 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function getID(): string |
| 33 | 33 | { |
| 34 | - if (empty($this->id)) { |
|
| 34 | + if (empty($this->id)) |
|
| 35 | + { |
|
| 35 | 36 | $this->id = \md5(\serialize($this->values)); |
| 36 | 37 | } |
| 37 | 38 | |
@@ -40,7 +41,8 @@ discard block |
||
| 40 | 41 | |
| 41 | 42 | public function set(string $name, mixed $value): self |
| 42 | 43 | { |
| 43 | - if (\array_key_exists($name, $this->values) && !$this->overwrite) { |
|
| 44 | + if (\array_key_exists($name, $this->values) && !$this->overwrite) |
|
| 45 | + { |
|
| 44 | 46 | return $this; |
| 45 | 47 | } |
| 46 | 48 | |
@@ -54,7 +56,8 @@ discard block |
||
| 54 | 56 | |
| 55 | 57 | public function get(string $name, mixed $default = null): mixed |
| 56 | 58 | { |
| 57 | - if (isset($this->values[$name])) { |
|
| 59 | + if (isset($this->values[$name])) |
|
| 60 | + { |
|
| 58 | 61 | return $this->normalize($this->values[$name]); |
| 59 | 62 | } |
| 60 | 63 | |
@@ -68,7 +71,8 @@ discard block |
||
| 68 | 71 | { |
| 69 | 72 | $result = []; |
| 70 | 73 | |
| 71 | - foreach ($this->values as $key => $value) { |
|
| 74 | + foreach ($this->values as $key => $value) |
|
| 75 | + { |
|
| 72 | 76 | $result[$key] = $this->normalize($value); |
| 73 | 77 | } |
| 74 | 78 | |
@@ -77,12 +81,14 @@ discard block |
||
| 77 | 81 | |
| 78 | 82 | protected function normalize(mixed $value): mixed |
| 79 | 83 | { |
| 80 | - if (!\is_string($value)) { |
|
| 84 | + if (!\is_string($value)) |
|
| 85 | + { |
|
| 81 | 86 | return $value; |
| 82 | 87 | } |
| 83 | 88 | |
| 84 | 89 | $alias = \strtolower($value); |
| 85 | - if (isset(self::VALUE_MAP[$alias])) { |
|
| 90 | + if (isset(self::VALUE_MAP[$alias])) |
|
| 91 | + { |
|
| 86 | 92 | return self::VALUE_MAP[$alias]; |
| 87 | 93 | } |
| 88 | 94 | |