Passed
Push — master ( 484e36...59734e )
by Jakub
01:04
created
src/ILoader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@
 block discarded – undo
3 3
 
4 4
 namespace Nexendrie\Translation;
5 5
 
6
-if (false) { // @phpstan-ignore if.alwaysFalse
6
+if(false) { // @phpstan-ignore if.alwaysFalse
7 7
     /** @deprecated Use Loader */
8 8
     interface ILoader extends Loader
9 9
     {
10 10
     }
11
-} elseif (!interface_exists(ILoader::class)) {
11
+} elseif(!interface_exists(ILoader::class)) {
12 12
     class_alias(Loader::class, ILoader::class);
13 13
 }
Please login to merge, or discard this patch.
src/Translator.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     private function extractDomainAndMessage(string $message): array
63 63
     {
64
-        if (!str_contains($message, ".")) {
64
+        if(!str_contains($message, ".")) {
65 65
             return [self::DEFAULT_DOMAIN, $message];
66 66
         }
67 67
         return explode(".", $message, 2);
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
     private function multiLevelTrans(array $message, array $texts): string
74 74
     {
75 75
         $text = $texts;
76
-        foreach ($message as $part) {
76
+        foreach($message as $part) {
77 77
             $text = Arrays::get($text, $part, "");
78
-            if ($text === "") {
78
+            if($text === "") {
79 79
                 break;
80 80
             }
81 81
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     public function translate($message, ...$parameters): string
99 99
     {
100 100
         $message = (string) $message;
101
-        if (count($parameters) === 1 && is_array($parameters[0])) {
101
+        if(count($parameters) === 1 && is_array($parameters[0])) {
102 102
             $count = $parameters[0]["count"] ?? 0;
103 103
             $params = $parameters[0];
104 104
         } else {
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
         [$domain, $m] = $this->extractDomainAndMessage($message);
109 109
         $texts = Arrays::get($this->loader->getTexts(), $domain, []);
110 110
         $parts = explode(".", $m);
111
-        if (count($parts) === 1) {
111
+        if(count($parts) === 1) {
112 112
             $parts = [$m];
113 113
         }
114 114
         $text = $this->multiLevelTrans($parts, $texts);
115
-        if ($text === "") {
115
+        if($text === "") {
116 116
             $this->onUntranslated($message);
117 117
             return $message;
118 118
         }
119
-        if ($this->messageSelector->isMultiChoice($text)) {
119
+        if($this->messageSelector->isMultiChoice($text)) {
120 120
             $text = $this->messageSelector->choose($text, $count);
121 121
         }
122
-        foreach ($params as $key => $value) {
122
+        foreach($params as $key => $value) {
123 123
             $text = str_replace("%$key%", (string) $value, $text);
124 124
         }
125 125
         return $text;
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 declare(strict_types=1);
3 3
 
4 4
 require __DIR__ . "/../vendor/autoload.php";
5
-Testbench\Bootstrap::setup(__DIR__ . '/_temp', function (\Nette\Bootstrap\Configurator $configurator): void {
5
+Testbench\Bootstrap::setup(__DIR__ . '/_temp', function(\Nette\Bootstrap\Configurator $configurator): void {
6 6
     $configurator->addStaticParameters([
7 7
         "appDir" => __DIR__,
8 8
         "tempDir" => __DIR__ . "/_temp",
Please login to merge, or discard this patch.
tests/Nexendrie/Translation/Loaders/FileLoaderTestAbstract.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function testSetFolders(): void
44 44
     {
45
-        Assert::exception(function (): void {
45
+        Assert::exception(function(): void {
46 46
             $this->loader->folders = [""];
47 47
         }, InvalidFolderException::class, "Folder  does not exist.");
48 48
     }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         Assert::count(2, $resources["book"]);
72 72
         Assert::count(2, $resources["abc"]);
73 73
         // the language does not exist, 1 (default) resource for each domain
74
-        if ($this->loader instanceof MessagesCatalogue) {
74
+        if($this->loader instanceof MessagesCatalogue) {
75 75
             return; // the following tests for some reason fail with MessagesCatalogue
76 76
         }
77 77
         $this->loader->lang = "xyz";
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         Assert::count(3, $texts["messages"]);
102 102
         Assert::type("array", $texts["book"]);
103 103
         Assert::count(5, $texts["book"]);
104
-        if ($this->loader instanceof MessagesCatalogue) {
104
+        if($this->loader instanceof MessagesCatalogue) {
105 105
             return; // the following tests for some reason fail with MessagesCatalogue
106 106
         }
107 107
         $this->loader->lang = "xyz";
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
     public function testNoFolder(): void
118 118
     {
119
-        Assert::exception(function (): void {
119
+        Assert::exception(function(): void {
120 120
             $class = get_class($this->loader);
121 121
             $this->loader = new $class();
122 122
             $this->loader->getTexts();
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         Assert::count(2, $result);
131 131
         Assert::contains("en", $result);
132 132
         Assert::contains("cs", $result);
133
-        Assert::exception(function (): void {
133
+        Assert::exception(function(): void {
134 134
             $class = get_class($this->loader);
135 135
             $this->loader = new $class();
136 136
             $this->loader->getAvailableLanguages();
Please login to merge, or discard this patch.
tests/Nexendrie/Translation/Bridges/NetteDI/TranslationExtensionTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
                 ]
115 115
             ]
116 116
         ];
117
-        Assert::exception(function () use ($config) {
117
+        Assert::exception(function() use ($config) {
118 118
             $this->refreshContainer($config);
119 119
         }, InvalidLoaderException::class);
120 120
         $config = [
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
                 ]
125 125
             ]
126 126
         ];
127
-        Assert::exception(function () use ($config) {
127
+        Assert::exception(function() use ($config) {
128 128
             $this->refreshContainer($config);
129 129
         }, InvalidLoaderException::class);
130 130
     }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
                 "localeResolver" => "invalid"
176 176
             ]
177 177
         ];
178
-        Assert::exception(function () use ($config) {
178
+        Assert::exception(function() use ($config) {
179 179
             $this->refreshContainer($config);
180 180
         }, InvalidLocaleResolverException::class);
181 181
         $config = [
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
                 "localeResolver" => \stdClass::class
184 184
             ]
185 185
         ];
186
-        Assert::exception(function () use ($config) {
186
+        Assert::exception(function() use ($config) {
187 187
             $this->refreshContainer($config);
188 188
         }, InvalidLocaleResolverException::class);
189 189
     }
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
                 ]
251 251
             ]
252 252
         ];
253
-        Assert::exception(function () use ($config) {
253
+        Assert::exception(function() use ($config) {
254 254
             $this->refreshContainer($config);
255 255
         }, InvalidFolderException::class);
256 256
     }
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 "messageSelector" => \stdClass::class
283 283
             ]
284 284
         ];
285
-        Assert::exception(function () use ($config) {
285
+        Assert::exception(function() use ($config) {
286 286
             $this->refreshContainer($config);
287 287
         }, InvalidMessageSelectorException::class);
288 288
     }
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
                 "debugger" => false
299 299
             ]
300 300
         ];
301
-        Assert::exception(function () use ($config) {
301
+        Assert::exception(function() use ($config) {
302 302
             $this->refreshContainer($config);
303 303
             $panel = $this->getService(TranslationPanel::class);
304 304
             Assert::type(TranslationPanel::class, $panel);
Please login to merge, or discard this patch.
tests/Nexendrie/Translation/Bridges/Tracy/TranslationPanelTest.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -41,24 +41,24 @@
 block discarded – undo
41 41
         $text = (string) $r->p;
42 42
         Assert::same("Untranslated messages: 0, loaded resources 0", $text);
43 43
         Assert::same("Resolved language", (string) $r->div->div->h1);
44
-        foreach ($r->div->div->table->tr->children() as $i => $td) {
45
-            if ($i === 0) {
44
+        foreach($r->div->div->table->tr->children() as $i => $td) {
45
+            if($i === 0) {
46 46
                 Assert::same("ManualLocaleResolver", (string) $td);
47
-            } elseif ($i === 1) {
47
+            } elseif($i === 1) {
48 48
                 Assert::same("en", (string) $td);
49 49
             }
50 50
         }
51
-        foreach ($r->children() as $i1 => $div) {
52
-            if ($i1 === 1) {
51
+        foreach($r->children() as $i1 => $div) {
52
+            if($i1 === 1) {
53 53
                 Assert::same("Loaded resources", (string) $div->h1);
54
-                foreach ($div->table->th as $i2 => $td) {
55
-                    if ($i2 === 0) {
54
+                foreach($div->table->th as $i2 => $td) {
55
+                    if($i2 === 0) {
56 56
                         Assert::same("Domain", (string) $td);
57
-                    } elseif ($i2 === 1) {
57
+                    } elseif($i2 === 1) {
58 58
                         Assert::same("Filename", (string) $td);
59 59
                     }
60 60
                 }
61
-            } elseif ($i1 === 2) {
61
+            } elseif($i1 === 2) {
62 62
                 Assert::count(0, $div->children());
63 63
             }
64 64
         }
Please login to merge, or discard this patch.
Nexendrie/Translation/Bridges/NetteApplication/ParamLocaleResolverTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     public function testResolve(): void
34 34
     {
35 35
         $parameters = [
36
-            "callback" => function () {
36
+            "callback" => function() {
37 37
                 return "";
38 38
             }
39 39
         ];
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $this->resolver->param = "language";
56 56
         $parameters = [
57
-            "callback" => function () {
57
+            "callback" => function() {
58 58
                 return "";
59 59
             }, "language" => "en",
60 60
         ];
Please login to merge, or discard this patch.
tests/Nexendrie/Translation/CustomMessageSelector.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
 
21 21
     public function choose(string $message, int $count): string
22 22
     {
23
-        if (!$this->isMultiChoice($message)) {
23
+        if(!$this->isMultiChoice($message)) {
24 24
             return $message;
25 25
         }
26 26
         $variants = explode("|", $message);
27
-        foreach ($variants as $variant) {
27
+        foreach($variants as $variant) {
28 28
             $interval = Intervals::findInterval($variant);
29
-            if (is_string($interval) && Intervals::isInInterval($count, $interval)) {
29
+            if(is_string($interval) && Intervals::isInInterval($count, $interval)) {
30 30
                 return Strings::trim((string) Strings::after($variant, $interval));
31 31
             }
32 32
         }
Please login to merge, or discard this patch.
tests/Nexendrie/Translation/Resolvers/HeaderLocaleResolverTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
     public function testResolve(): void
31 31
     {
32 32
         $resolver = new HeaderLocaleResolver();
33
-        Assert::exception(function () use ($resolver) {
33
+        Assert::exception(function() use ($resolver) {
34 34
             $resolver->resolve();
35 35
         }, LoaderNotSetException::class);
36 36
         /** @var Loader $loader */
Please login to merge, or discard this patch.