@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | public function __construct( |
32 | 32 | private readonly TranslatorConfig $config, |
33 | 33 | private readonly CatalogueInterface $catalogue |
34 | - ) { |
|
34 | + ){ |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function registerMessage(string $domain, string $string, bool $resolveDomain = true): void |
41 | 41 | { |
42 | - if ($resolveDomain) { |
|
42 | + if ($resolveDomain){ |
|
43 | 43 | $domain = $this->config->resolveDomain($domain); |
44 | 44 | } |
45 | 45 | |
46 | 46 | //Automatically registering |
47 | - if (!$this->catalogue->has($domain, $string)) { |
|
47 | + if (!$this->catalogue->has($domain, $string)){ |
|
48 | 48 | $this->catalogue->set($domain, $string, $string); |
49 | 49 | } |
50 | 50 | |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function indexClasses(ScopedClassesInterface $locator): void |
62 | 62 | { |
63 | - foreach ($locator->getScopedClasses('translations', TranslatorTrait::class) as $class) { |
|
63 | + foreach ($locator->getScopedClasses('translations', TranslatorTrait::class) as $class){ |
|
64 | 64 | $strings = $this->fetchMessages($class, true); |
65 | - foreach ($strings as $string) { |
|
65 | + foreach ($strings as $string){ |
|
66 | 66 | $this->registerMessage($class->getName(), $string); |
67 | 67 | } |
68 | 68 | } |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | */ |
95 | 95 | private function registerInvocations(array $invocations): void |
96 | 96 | { |
97 | - foreach ($invocations as $invocation) { |
|
98 | - if ($invocation->getArgument(0)->getType() != ReflectionArgument::STRING) { |
|
97 | + foreach ($invocations as $invocation){ |
|
98 | + if ($invocation->getArgument(0)->getType() != ReflectionArgument::STRING){ |
|
99 | 99 | //We can only index invocations with constant string arguments |
100 | 100 | continue; |
101 | 101 | } |
@@ -114,20 +114,20 @@ discard block |
||
114 | 114 | { |
115 | 115 | $target = $reflection->getDefaultProperties() + $reflection->getConstants(); |
116 | 116 | |
117 | - foreach ($reflection->getProperties() as $property) { |
|
118 | - if (\is_string($property->getDocComment()) && \strpos($property->getDocComment(), '@do-not-index')) { |
|
117 | + foreach ($reflection->getProperties() as $property){ |
|
118 | + if (\is_string($property->getDocComment()) && \strpos($property->getDocComment(), '@do-not-index')){ |
|
119 | 119 | unset($target[$property->getName()]); |
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | 123 | $strings = []; |
124 | 124 | \array_walk_recursive($target, function ($value) use (&$strings): void { |
125 | - if (\is_string($value) && Translator::isMessage($value)) { |
|
125 | + if (\is_string($value) && Translator::isMessage($value)){ |
|
126 | 126 | $strings[] = $this->prepareMessage($value); |
127 | 127 | } |
128 | 128 | }); |
129 | 129 | |
130 | - if ($inherit && $reflection->getParentClass()) { |
|
130 | + if ($inherit && $reflection->getParentClass()){ |
|
131 | 131 | //Joining strings data with parent class values (inheritance ON) - resolved into same |
132 | 132 | //domain on export |
133 | 133 | $strings = \array_merge( |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | //Translation using default bundle |
148 | 148 | $domain = $this->config->getDefaultDomain(); |
149 | 149 | |
150 | - if ($invocation->getName() === 'say') { |
|
150 | + if ($invocation->getName() === 'say'){ |
|
151 | 151 | //Let's try to confirm domain |
152 | 152 | $domain = $this->config->resolveDomain($invocation->getClass()); |
153 | 153 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | default => null |
160 | 160 | }; |
161 | 161 | |
162 | - if (!empty($argument) && $argument->getType() === ReflectionArgument::STRING) { |
|
162 | + if (!empty($argument) && $argument->getType() === ReflectionArgument::STRING){ |
|
163 | 163 | //Domain specified in arguments |
164 | 164 | $domain = $this->config->resolveDomain($argument->stringValue()); |
165 | 165 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | private function prepareMessage(string $string): string |
174 | 174 | { |
175 | - if (Translator::isMessage($string)) { |
|
175 | + if (Translator::isMessage($string)){ |
|
176 | 176 | $string = \substr($string, 2, -2); |
177 | 177 | } |
178 | 178 |
@@ -39,12 +39,14 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function registerMessage(string $domain, string $string, bool $resolveDomain = true): void |
41 | 41 | { |
42 | - if ($resolveDomain) { |
|
42 | + if ($resolveDomain) |
|
43 | + { |
|
43 | 44 | $domain = $this->config->resolveDomain($domain); |
44 | 45 | } |
45 | 46 | |
46 | 47 | //Automatically registering |
47 | - if (!$this->catalogue->has($domain, $string)) { |
|
48 | + if (!$this->catalogue->has($domain, $string)) |
|
49 | + { |
|
48 | 50 | $this->catalogue->set($domain, $string, $string); |
49 | 51 | } |
50 | 52 | |
@@ -60,9 +62,11 @@ discard block |
||
60 | 62 | */ |
61 | 63 | public function indexClasses(ScopedClassesInterface $locator): void |
62 | 64 | { |
63 | - foreach ($locator->getScopedClasses('translations', TranslatorTrait::class) as $class) { |
|
65 | + foreach ($locator->getScopedClasses('translations', TranslatorTrait::class) as $class) |
|
66 | + { |
|
64 | 67 | $strings = $this->fetchMessages($class, true); |
65 | - foreach ($strings as $string) { |
|
68 | + foreach ($strings as $string) |
|
69 | + { |
|
66 | 70 | $this->registerMessage($class->getName(), $string); |
67 | 71 | } |
68 | 72 | } |
@@ -94,8 +98,10 @@ discard block |
||
94 | 98 | */ |
95 | 99 | private function registerInvocations(array $invocations): void |
96 | 100 | { |
97 | - foreach ($invocations as $invocation) { |
|
98 | - if ($invocation->getArgument(0)->getType() != ReflectionArgument::STRING) { |
|
101 | + foreach ($invocations as $invocation) |
|
102 | + { |
|
103 | + if ($invocation->getArgument(0)->getType() != ReflectionArgument::STRING) |
|
104 | + { |
|
99 | 105 | //We can only index invocations with constant string arguments |
100 | 106 | continue; |
101 | 107 | } |
@@ -114,20 +120,24 @@ discard block |
||
114 | 120 | { |
115 | 121 | $target = $reflection->getDefaultProperties() + $reflection->getConstants(); |
116 | 122 | |
117 | - foreach ($reflection->getProperties() as $property) { |
|
118 | - if (\is_string($property->getDocComment()) && \strpos($property->getDocComment(), '@do-not-index')) { |
|
123 | + foreach ($reflection->getProperties() as $property) |
|
124 | + { |
|
125 | + if (\is_string($property->getDocComment()) && \strpos($property->getDocComment(), '@do-not-index')) |
|
126 | + { |
|
119 | 127 | unset($target[$property->getName()]); |
120 | 128 | } |
121 | 129 | } |
122 | 130 | |
123 | 131 | $strings = []; |
124 | 132 | \array_walk_recursive($target, function ($value) use (&$strings): void { |
125 | - if (\is_string($value) && Translator::isMessage($value)) { |
|
133 | + if (\is_string($value) && Translator::isMessage($value)) |
|
134 | + { |
|
126 | 135 | $strings[] = $this->prepareMessage($value); |
127 | 136 | } |
128 | 137 | }); |
129 | 138 | |
130 | - if ($inherit && $reflection->getParentClass()) { |
|
139 | + if ($inherit && $reflection->getParentClass()) |
|
140 | + { |
|
131 | 141 | //Joining strings data with parent class values (inheritance ON) - resolved into same |
132 | 142 | //domain on export |
133 | 143 | $strings = \array_merge( |
@@ -147,7 +157,8 @@ discard block |
||
147 | 157 | //Translation using default bundle |
148 | 158 | $domain = $this->config->getDefaultDomain(); |
149 | 159 | |
150 | - if ($invocation->getName() === 'say') { |
|
160 | + if ($invocation->getName() === 'say') |
|
161 | + { |
|
151 | 162 | //Let's try to confirm domain |
152 | 163 | $domain = $this->config->resolveDomain($invocation->getClass()); |
153 | 164 | } |
@@ -159,7 +170,8 @@ discard block |
||
159 | 170 | default => null |
160 | 171 | }; |
161 | 172 | |
162 | - if (!empty($argument) && $argument->getType() === ReflectionArgument::STRING) { |
|
173 | + if (!empty($argument) && $argument->getType() === ReflectionArgument::STRING) |
|
174 | + { |
|
163 | 175 | //Domain specified in arguments |
164 | 176 | $domain = $this->config->resolveDomain($argument->stringValue()); |
165 | 177 | } |
@@ -172,7 +184,8 @@ discard block |
||
172 | 184 | */ |
173 | 185 | private function prepareMessage(string $string): string |
174 | 186 | { |
175 | - if (Translator::isMessage($string)) { |
|
187 | + if (Translator::isMessage($string)) |
|
188 | + { |
|
176 | 189 | $string = \substr($string, 2, -2); |
177 | 190 | } |
178 | 191 |