@@ -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); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | public function __construct( |
19 | 19 | private readonly ActorProviderInterface $actorProvider, |
20 | 20 | private readonly ?EventDispatcherInterface $eventDispatcher = null |
21 | - ) { |
|
21 | + ){ |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function start(TokenInterface $token, ?string $transport = null): void |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | |
44 | 44 | public function getActor(): ?object |
45 | 45 | { |
46 | - if ($this->closed) { |
|
46 | + if ($this->closed){ |
|
47 | 47 | return null; |
48 | 48 | } |
49 | 49 | |
50 | - if ($this->actor === null && $this->token !== null) { |
|
50 | + if ($this->actor === null && $this->token !== null){ |
|
51 | 51 | $this->actor = $this->actorProvider->getActor($this->token); |
52 | 52 | } |
53 | 53 |
@@ -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 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** @internal */ |
28 | 28 | private readonly IdentityTranslator $identityTranslator = new IdentityTranslator(), |
29 | 29 | private readonly ?EventDispatcherInterface $dispatcher = null, |
30 | - ) { |
|
30 | + ){ |
|
31 | 31 | $this->locale = $this->config->getDefaultLocale(); |
32 | 32 | $this->catalogueManager->load($this->locale); |
33 | 33 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function setLocale(string $locale): void |
44 | 44 | { |
45 | - if (!$this->catalogueManager->has($locale)) { |
|
45 | + if (!$this->catalogueManager->has($locale)){ |
|
46 | 46 | throw new LocaleException($locale); |
47 | 47 | } |
48 | 48 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function transChoice( |
88 | 88 | string $id, |
89 | - string|int $number, |
|
89 | + string | int $number, |
|
90 | 90 | array $parameters = [], |
91 | 91 | ?string $domain = null, |
92 | 92 | ?string $locale = null |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $domain ??= $this->config->getDefaultDomain(); |
95 | 95 | $locale ??= $this->locale; |
96 | 96 | |
97 | - try { |
|
97 | + try{ |
|
98 | 98 | $message = $this->get($locale, $domain, $id); |
99 | 99 | |
100 | 100 | $pluralized = $this->identityTranslator->trans( |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | null, |
104 | 104 | $locale |
105 | 105 | ); |
106 | - } catch (\InvalidArgumentException $e) { |
|
106 | + }catch (\InvalidArgumentException $e){ |
|
107 | 107 | //Wrapping into more explanatory exception |
108 | 108 | throw new PluralizationException($e->getMessage(), $e->getCode(), $e); |
109 | 109 | } |
110 | 110 | |
111 | - if (empty($parameters['n']) && is_numeric($number)) { |
|
111 | + if (empty($parameters['n']) && is_numeric($number)){ |
|
112 | 112 | $parameters['n'] = $number; |
113 | 113 | } |
114 | 114 | |
@@ -132,18 +132,18 @@ discard block |
||
132 | 132 | string $postfix = '}' |
133 | 133 | ): string { |
134 | 134 | $replaces = []; |
135 | - foreach ($values as $key => $value) { |
|
135 | + foreach ($values as $key => $value){ |
|
136 | 136 | $value = (\is_array($value) || $value instanceof \Closure) ? '' : $value; |
137 | 137 | |
138 | - if (\is_object($value)) { |
|
139 | - if (\method_exists($value, '__toString')) { |
|
138 | + if (\is_object($value)){ |
|
139 | + if (\method_exists($value, '__toString')){ |
|
140 | 140 | $value = $value->__toString(); |
141 | - } else { |
|
141 | + }else{ |
|
142 | 142 | $value = ''; |
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | - $replaces[$prefix . $key . $postfix] = $value; |
|
146 | + $replaces[$prefix.$key.$postfix] = $value; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return \strtr($string, $replaces); |
@@ -163,18 +163,18 @@ discard block |
||
163 | 163 | */ |
164 | 164 | protected function get(string &$locale, string $domain, string $string): string |
165 | 165 | { |
166 | - if ($this->catalogueManager->get($locale)->has($domain, $string)) { |
|
166 | + if ($this->catalogueManager->get($locale)->has($domain, $string)){ |
|
167 | 167 | return $this->catalogueManager->get($locale)->get($domain, $string); |
168 | 168 | } |
169 | 169 | |
170 | 170 | $locale = $this->config->getFallbackLocale(); |
171 | 171 | |
172 | - if ($this->catalogueManager->get($locale)->has($domain, $string)) { |
|
172 | + if ($this->catalogueManager->get($locale)->has($domain, $string)){ |
|
173 | 173 | return $this->catalogueManager->get($locale)->get($domain, $string); |
174 | 174 | } |
175 | 175 | |
176 | 176 | // we can automatically register message |
177 | - if ($this->config->isAutoRegisterMessages()) { |
|
177 | + if ($this->config->isAutoRegisterMessages()){ |
|
178 | 178 | $this->catalogueManager->get($locale)->set($domain, $string, $string); |
179 | 179 | $this->catalogueManager->save($locale); |
180 | 180 | } |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | public function __construct( |
25 | 25 | private readonly LoaderInterface $loader, |
26 | 26 | ?CacheInterface $cache = null |
27 | - ) { |
|
27 | + ){ |
|
28 | 28 | $this->cache = $cache ?? new NullCache(); |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function getLocales(): array |
32 | 32 | { |
33 | - if ($this->locales !== []) { |
|
33 | + if ($this->locales !== []){ |
|
34 | 34 | return $this->locales; |
35 | 35 | } |
36 | 36 | |
37 | 37 | $this->locales = (array)$this->cache->getLocales(); |
38 | - if ($this->locales === []) { |
|
38 | + if ($this->locales === []){ |
|
39 | 39 | $this->locales = $this->loader->getLocales(); |
40 | 40 | $this->cache->setLocales($this->locales); |
41 | 41 | } |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | |
46 | 46 | public function load(string $locale): CatalogueInterface |
47 | 47 | { |
48 | - if (isset($this->catalogues[$locale])) { |
|
48 | + if (isset($this->catalogues[$locale])){ |
|
49 | 49 | return $this->catalogues[$locale]; |
50 | 50 | } |
51 | 51 | |
52 | 52 | $data = (array)$this->cache->loadLocale($locale); |
53 | - if (!empty($data)) { |
|
53 | + if (!empty($data)){ |
|
54 | 54 | $this->catalogues[$locale] = new Catalogue($locale, $data); |
55 | - } else { |
|
55 | + }else{ |
|
56 | 56 | $this->catalogues[$locale] = $this->loader->loadCatalogue($locale); |
57 | 57 | } |
58 | 58 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | public function reset(): void |
81 | 81 | { |
82 | 82 | $this->cache->setLocales(null); |
83 | - foreach ($this->getLocales() as $locale) { |
|
83 | + foreach ($this->getLocales() as $locale){ |
|
84 | 84 | $this->cache->saveLocale($locale, null); |
85 | 85 | } |
86 | 86 |
@@ -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 | } |
@@ -10,10 +10,10 @@ |
||
10 | 10 | |
11 | 11 | public function __construct(?\Throwable $previous = null) |
12 | 12 | { |
13 | - parent::__construct((string) $previous?->getMessage(), (int) ($previous?->getCode() ?? 0), $previous); |
|
13 | + parent::__construct((string)$previous?->getMessage(), (int)($previous?->getCode() ?? 0), $previous); |
|
14 | 14 | |
15 | - $this->file = (string) $previous?->getFile(); |
|
16 | - $this->line = (int) $previous?->getLine(); |
|
15 | + $this->file = (string)$previous?->getFile(); |
|
16 | + $this->line = (int)$previous?->getLine(); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |