@@ -16,15 +16,15 @@ |
||
16 | 16 | */ |
17 | 17 | public function __construct(array $loaders = []) |
18 | 18 | { |
19 | - foreach ($loaders as $loader) { |
|
19 | + foreach ($loaders as $loader){ |
|
20 | 20 | $this->addLoader($loader); |
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | - public function resolve(mixed $resource, ?string $type = null): LoaderInterface|false |
|
24 | + public function resolve(mixed $resource, ?string $type = null): LoaderInterface | false |
|
25 | 25 | { |
26 | - foreach ($this->loaders as $loader) { |
|
27 | - if ($loader->supports($resource, $type)) { |
|
26 | + foreach ($this->loaders as $loader){ |
|
27 | + if ($loader->supports($resource, $type)){ |
|
28 | 28 | return $loader; |
29 | 29 | } |
30 | 30 | } |
@@ -16,15 +16,18 @@ |
||
16 | 16 | */ |
17 | 17 | public function __construct(array $loaders = []) |
18 | 18 | { |
19 | - foreach ($loaders as $loader) { |
|
19 | + foreach ($loaders as $loader) |
|
20 | + { |
|
20 | 21 | $this->addLoader($loader); |
21 | 22 | } |
22 | 23 | } |
23 | 24 | |
24 | 25 | public function resolve(mixed $resource, ?string $type = null): LoaderInterface|false |
25 | 26 | { |
26 | - foreach ($this->loaders as $loader) { |
|
27 | - if ($loader->supports($resource, $type)) { |
|
27 | + foreach ($this->loaders as $loader) |
|
28 | + { |
|
29 | + if ($loader->supports($resource, $type)) |
|
30 | + { |
|
28 | 31 | return $loader; |
29 | 32 | } |
30 | 33 | } |
@@ -10,12 +10,12 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | private readonly LoaderRegistryInterface $registry |
13 | - ) { |
|
13 | + ){ |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public function load(mixed $resource, ?string $type = null): mixed |
17 | 17 | { |
18 | - if (false === $loader = $this->registry->resolve($resource, $type)) { |
|
18 | + if (false === $loader = $this->registry->resolve($resource, $type)){ |
|
19 | 19 | throw new LoaderLoadException(\sprintf('Loader for type [%s] not found.', $type ?? '')); |
20 | 20 | } |
21 | 21 |
@@ -15,7 +15,8 @@ |
||
15 | 15 | |
16 | 16 | public function load(mixed $resource, ?string $type = null): mixed |
17 | 17 | { |
18 | - if (false === $loader = $this->registry->resolve($resource, $type)) { |
|
18 | + if (false === $loader = $this->registry->resolve($resource, $type)) |
|
19 | + { |
|
19 | 20 | throw new LoaderLoadException(\sprintf('Loader for type [%s] not found.', $type ?? '')); |
20 | 21 | } |
21 | 22 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | public function __construct( |
17 | 17 | private readonly FactoryInterface $factory, |
18 | 18 | private readonly ResolverInterface $resolver, |
19 | - ) { |
|
19 | + ){ |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function load(mixed $resource, ?string $type = null): RouteCollection |
26 | 26 | { |
27 | - if (!\file_exists($resource)) { |
|
27 | + if (!\file_exists($resource)){ |
|
28 | 28 | throw new LoaderLoadException(\sprintf('File [%s] does not exist.', $resource)); |
29 | 29 | } |
30 | 30 |
@@ -24,7 +24,8 @@ |
||
24 | 24 | */ |
25 | 25 | public function load(mixed $resource, ?string $type = null): RouteCollection |
26 | 26 | { |
27 | - if (!\file_exists($resource)) { |
|
27 | + if (!\file_exists($resource)) |
|
28 | + { |
|
28 | 29 | throw new LoaderLoadException(\sprintf('File [%s] does not exist.', $resource)); |
29 | 30 | } |
30 | 31 |
@@ -11,5 +11,5 @@ |
||
11 | 11 | * |
12 | 12 | * @param string|null $type The resource type or null if unknown |
13 | 13 | */ |
14 | - public function resolve(mixed $resource, ?string $type = null): LoaderInterface|false; |
|
14 | + public function resolve(mixed $resource, ?string $type = null): LoaderInterface | false; |
|
15 | 15 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public function __construct( |
10 | 10 | protected readonly SerializerRegistry $serializers, |
11 | 11 | protected readonly string $defaultFormat |
12 | - ) { |
|
12 | + ){ |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | public function getSerializer(?string $format = null): SerializerInterface |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | return $this->serializers->get($format ?? $this->defaultFormat); |
18 | 18 | } |
19 | 19 | |
20 | - public function serialize(mixed $payload, ?string $format = null): string|\Stringable |
|
20 | + public function serialize(mixed $payload, ?string $format = null): string | \Stringable |
|
21 | 21 | { |
22 | 22 | return $this->getSerializer($format ?? $this->defaultFormat)->serialize($payload); |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function unserialize( |
26 | - string|\Stringable $payload, |
|
27 | - string|object|null $type = null, |
|
26 | + string | \Stringable $payload, |
|
27 | + string | object | null $type = null, |
|
28 | 28 | ?string $format = null |
29 | 29 | ): mixed { |
30 | 30 | return $this->getSerializer($format ?? $this->defaultFormat)->unserialize($payload, $type); |
@@ -19,26 +19,26 @@ discard block |
||
19 | 19 | { |
20 | 20 | public function __construct( |
21 | 21 | private readonly CacheStorageProviderInterface $provider |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function createInjection(ReflectionClass $class, ?string $context = null): CacheInterface |
26 | 26 | { |
27 | - try { |
|
28 | - if ($context === null) { |
|
27 | + try{ |
|
28 | + if ($context === null){ |
|
29 | 29 | $connection = $this->provider->storage(); |
30 | - } else { |
|
30 | + }else{ |
|
31 | 31 | // Get Cache by context |
32 | - try { |
|
32 | + try{ |
|
33 | 33 | $connection = $this->provider->storage($context); |
34 | - } catch (InvalidArgumentException) { |
|
34 | + }catch (InvalidArgumentException){ |
|
35 | 35 | // Case when context doesn't match to configured connections |
36 | 36 | return $this->provider->storage(); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | 40 | $this->matchType($class, $context, $connection); |
41 | - } catch (\Throwable $e) { |
|
41 | + }catch (\Throwable $e){ |
|
42 | 42 | throw new ContainerException(sprintf("Can't inject the required cache. %s", $e->getMessage()), 0, $e); |
43 | 43 | } |
44 | 44 | |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | */ |
53 | 53 | private function matchType(ReflectionClass $class, ?string $context, CacheInterface $connection): void |
54 | 54 | { |
55 | - if ($connection::class === CacheRepository::class) { |
|
55 | + if ($connection::class === CacheRepository::class){ |
|
56 | 56 | $connection = $connection->getStorage(); |
57 | 57 | } |
58 | 58 | $className = $class->getName(); |
59 | - if ($className !== CacheInterface::class && !$connection instanceof $className) { |
|
59 | + if ($className !== CacheInterface::class && !$connection instanceof $className){ |
|
60 | 60 | throw new \RuntimeException( |
61 | 61 | \sprintf( |
62 | 62 | "The cache obtained by the context `%s` doesn't match the type `%s`.", |
@@ -24,21 +24,30 @@ discard block |
||
24 | 24 | |
25 | 25 | public function createInjection(ReflectionClass $class, ?string $context = null): CacheInterface |
26 | 26 | { |
27 | - try { |
|
28 | - if ($context === null) { |
|
27 | + try |
|
28 | + { |
|
29 | + if ($context === null) |
|
30 | + { |
|
29 | 31 | $connection = $this->provider->storage(); |
30 | - } else { |
|
32 | + } |
|
33 | + else |
|
34 | + { |
|
31 | 35 | // Get Cache by context |
32 | - try { |
|
36 | + try |
|
37 | + { |
|
33 | 38 | $connection = $this->provider->storage($context); |
34 | - } catch (InvalidArgumentException) { |
|
39 | + } |
|
40 | + catch (InvalidArgumentException) |
|
41 | + { |
|
35 | 42 | // Case when context doesn't match to configured connections |
36 | 43 | return $this->provider->storage(); |
37 | 44 | } |
38 | 45 | } |
39 | 46 | |
40 | 47 | $this->matchType($class, $context, $connection); |
41 | - } catch (\Throwable $e) { |
|
48 | + } |
|
49 | + catch (\Throwable $e) |
|
50 | + { |
|
42 | 51 | throw new ContainerException(sprintf("Can't inject the required cache. %s", $e->getMessage()), 0, $e); |
43 | 52 | } |
44 | 53 | |
@@ -52,11 +61,13 @@ discard block |
||
52 | 61 | */ |
53 | 62 | private function matchType(ReflectionClass $class, ?string $context, CacheInterface $connection): void |
54 | 63 | { |
55 | - if ($connection::class === CacheRepository::class) { |
|
64 | + if ($connection::class === CacheRepository::class) |
|
65 | + { |
|
56 | 66 | $connection = $connection->getStorage(); |
57 | 67 | } |
58 | 68 | $className = $class->getName(); |
59 | - if ($className !== CacheInterface::class && !$connection instanceof $className) { |
|
69 | + if ($className !== CacheInterface::class && !$connection instanceof $className) |
|
70 | + { |
|
60 | 71 | throw new \RuntimeException( |
61 | 72 | \sprintf( |
62 | 73 | "The cache obtained by the context `%s` doesn't match the type `%s`.", |
@@ -13,7 +13,7 @@ |
||
13 | 13 | protected string $locale, |
14 | 14 | int $code = 0, |
15 | 15 | ?\Throwable $previous = null |
16 | - ) { |
|
16 | + ){ |
|
17 | 17 | parent::__construct(\sprintf('Undefined locale \'%s\'', $locale), $code, $previous); |
18 | 18 | } |
19 | 19 |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | */ |
33 | 33 | protected function say(string $string, array $options = [], ?string $bundle = null): string |
34 | 34 | { |
35 | - if (Translator::isMessage($string)) { |
|
35 | + if (Translator::isMessage($string)){ |
|
36 | 36 | //Cut [[ and ]] |
37 | 37 | $string = \substr($string, 2, -2); |
38 | 38 | } |
39 | 39 | |
40 | 40 | $container = ContainerScope::getContainer(); |
41 | - if (empty($container) || !$container->has(TranslatorInterface::class)) { |
|
41 | + if (empty($container) || !$container->has(TranslatorInterface::class)){ |
|
42 | 42 | return Translator::interpolate($string, $options); |
43 | 43 | } |
44 | 44 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | $translator = $container->get(TranslatorInterface::class); |
49 | 49 | |
50 | - if (\is_null($bundle)) { |
|
50 | + if (\is_null($bundle)){ |
|
51 | 51 | $bundle = $translator->getDomain(static::class); |
52 | 52 | } |
53 | 53 |
@@ -32,13 +32,15 @@ discard block |
||
32 | 32 | */ |
33 | 33 | protected function say(string $string, array $options = [], ?string $bundle = null): string |
34 | 34 | { |
35 | - if (Translator::isMessage($string)) { |
|
35 | + if (Translator::isMessage($string)) |
|
36 | + { |
|
36 | 37 | //Cut [[ and ]] |
37 | 38 | $string = \substr($string, 2, -2); |
38 | 39 | } |
39 | 40 | |
40 | 41 | $container = ContainerScope::getContainer(); |
41 | - if (empty($container) || !$container->has(TranslatorInterface::class)) { |
|
42 | + if (empty($container) || !$container->has(TranslatorInterface::class)) |
|
43 | + { |
|
42 | 44 | return Translator::interpolate($string, $options); |
43 | 45 | } |
44 | 46 | |
@@ -47,7 +49,8 @@ discard block |
||
47 | 49 | */ |
48 | 50 | $translator = $container->get(TranslatorInterface::class); |
49 | 51 | |
50 | - if (\is_null($bundle)) { |
|
52 | + if (\is_null($bundle)) |
|
53 | + { |
|
51 | 54 | $bundle = $translator->getDomain(static::class); |
52 | 55 | } |
53 | 56 |
@@ -43,5 +43,5 @@ |
||
43 | 43 | * |
44 | 44 | * @throws LoaderException |
45 | 45 | */ |
46 | - public function list(?string $namespace = null): array; |
|
46 | + public function list(?string $namespace = null) : array; |
|
47 | 47 | } |