Passed
Push — master ( 484e36...59734e )
by Jakub
01:04
created
src/Loaders/PhpLoader.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@
 block discarded – undo
9 9
  *
10 10
  * @author Jakub Konečný
11 11
  */
12
-final class PhpLoader extends FileLoader
13
-{
12
+final class PhpLoader extends FileLoader {
14 13
     protected string $extension = "php";
15 14
 
16 15
     protected function parseFile(string $filename): array
Please login to merge, or discard this patch.
src/Loaders/IniLoader.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
     protected function parseFile(string $filename): array
20 20
     {
21 21
         $result = parse_ini_file($filename, true);
22
-        if ($result === false) {
22
+        if($result === false) {
23 23
             throw new \RuntimeException("File $filename does not exist or cannot be read.");
24 24
         }
25 25
         return $result;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@
 block discarded – undo
9 9
  *
10 10
  * @author Jakub Konečný
11 11
  */
12
-final class IniLoader extends FileLoader
13
-{
12
+final class IniLoader extends FileLoader {
14 13
     protected string $extension = "ini";
15 14
 
16 15
     /**
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
     {
21 21
         $result = parse_ini_file($filename, true);
22 22
         if ($result === false) {
23
-            throw new \RuntimeException("File $filename does not exist or cannot be read.");
23
+            throw new \RuntimeException("file $filename does not exist or cannot be read.");
24 24
         }
25 25
         return $result;
26 26
     }
Please login to merge, or discard this patch.
src/Loaders/YamlLoader.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@
 block discarded – undo
11 11
  *
12 12
  * @author Jakub Konečný
13 13
  */
14
-final class YamlLoader extends FileLoader
15
-{
14
+final class YamlLoader extends FileLoader {
16 15
     protected string $extension = "yaml";
17 16
 
18 17
     /**
Please login to merge, or discard this patch.
src/Loaders/FileLoader.php 3 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function setLang(string $lang): void
70 70
     {
71
-        if (is_a($this->resolver, SettableLocaleResolver::class)) {
71
+        if(is_a($this->resolver, SettableLocaleResolver::class)) {
72 72
             $oldLang = $this->lang;
73 73
             $this->resolver->setLang($lang);
74 74
             $this->onLanguageChange($this, $oldLang, $lang);
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public function setFolders(array $folders): void
109 109
     {
110
-        foreach ($folders as $folder) {
111
-            if (!is_dir($folder)) {
110
+        foreach($folders as $folder) {
111
+            if(!is_dir($folder)) {
112 112
                 throw new InvalidFolderException("Folder $folder does not exist.");
113 113
             }
114 114
             $this->folders[] = $folder;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
     protected function addResource(string $filename, string $domain): void
120 120
     {
121
-        if (!isset($this->resources[$domain]) || !in_array($filename, $this->resources[$domain], true)) {
121
+        if(!isset($this->resources[$domain]) || !in_array($filename, $this->resources[$domain], true)) {
122 122
             $this->resources[$domain][] = $filename;
123 123
         }
124 124
     }
@@ -145,20 +145,20 @@  discard block
 block discarded – undo
145 145
         $defaultLang = $this->defaultLang;
146 146
         $defaultFilename = $this->getLanguageFilenameMask();
147 147
         $defaultFilename = str_replace(
148
-            [static::DOMAIN_MASK, static::LANGUAGE_MASK,],
149
-            [$name, $defaultLang,],
148
+            [static::DOMAIN_MASK, static::LANGUAGE_MASK, ],
149
+            [$name, $defaultLang, ],
150 150
             $defaultFilename
151 151
         );
152 152
         $files = Finder::findFiles($defaultFilename)
153 153
             ->from(...$this->folders);
154 154
         /** @var \SplFileInfo $file */
155
-        foreach ($files as $file) {
155
+        foreach($files as $file) {
156 156
             $default = $this->parseFile($file->getPathname());
157 157
             $this->addResource($file->getPathname(), $name);
158 158
             $lang = [];
159 159
             $filename = str_replace($defaultLang, $this->lang, $defaultFilename);
160 160
             $filename = str_replace($defaultFilename, $filename, $file->getPathname());
161
-            if ($this->lang !== $defaultLang && is_file($filename)) {
161
+            if($this->lang !== $defaultLang && is_file($filename)) {
162 162
                 $lang = $this->parseFile($filename);
163 163
                 $this->addResource($filename, $name);
164 164
             }
@@ -174,20 +174,20 @@  discard block
 block discarded – undo
174 174
      */
175 175
     protected function loadTexts(): void
176 176
     {
177
-        if ($this->lang === $this->loadedLang) {
177
+        if($this->lang === $this->loadedLang) {
178 178
             return;
179 179
         }
180
-        if (count($this->folders) === 0) {
180
+        if(count($this->folders) === 0) {
181 181
             throw new FolderNotSetException("Folder for translations was not set.");
182 182
         }
183 183
         $default = $this->defaultLang;
184 184
         $this->resources = $texts = [];
185 185
         $mask = $this->getLanguageFilenameMask();
186
-        $mask = str_replace([static::DOMAIN_MASK, static::LANGUAGE_MASK,], ["*", $default,], $mask);
186
+        $mask = str_replace([static::DOMAIN_MASK, static::LANGUAGE_MASK, ], ["*", $default, ], $mask);
187 187
         $files = Finder::findFiles($mask)
188 188
             ->from(...$this->folders);
189 189
         /** @var \SplFileInfo $file */
190
-        foreach ($files as $file) {
190
+        foreach($files as $file) {
191 191
             $domain = $file->getBasename((string) Strings::after($mask, "*"));
192 192
             $texts[$domain] = $this->loadDomain($domain);
193 193
         }
@@ -222,20 +222,20 @@  discard block
 block discarded – undo
222 222
      */
223 223
     public function getAvailableLanguages(): array
224 224
     {
225
-        if (count($this->folders) === 0) {
225
+        if(count($this->folders) === 0) {
226 226
             throw new FolderNotSetException("Folder for translations was not set.");
227 227
         }
228 228
         $languages = [];
229 229
         $extension = $this->extension;
230 230
         $mask = $this->getLanguageFilenameMask();
231
-        $mask = str_replace([static::DOMAIN_MASK, static::LANGUAGE_MASK,], "*", $mask);
231
+        $mask = str_replace([static::DOMAIN_MASK, static::LANGUAGE_MASK, ], "*", $mask);
232 232
         $files = Finder::findFiles($mask)
233 233
             ->from(...$this->folders);
234 234
         /** @var \SplFileInfo $file */
235
-        foreach ($files as $file) {
235
+        foreach($files as $file) {
236 236
             $filename = $file->getBasename(".$extension");
237 237
             $lang = (string) Strings::after($filename, ".");
238
-            if (!in_array($lang, $languages, true)) {
238
+            if(!in_array($lang, $languages, true)) {
239 239
                 $languages[] = $lang;
240 240
             }
241 241
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,8 +50,7 @@
 block discarded – undo
50 50
     /**
51 51
      * @param string[] $folders
52 52
      */
53
-    public function __construct(protected LocaleResolver $resolver = new ManualLocaleResolver(), array $folders = [])
54
-    {
53
+    public function __construct(protected LocaleResolver $resolver = new ManualLocaleResolver(), array $folders = []) {
55 54
         $this->setFolders($folders);
56 55
     }
57 56
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@
 block discarded – undo
109 109
     {
110 110
         foreach ($folders as $folder) {
111 111
             if (!is_dir($folder)) {
112
-                throw new InvalidFolderException("Folder $folder does not exist.");
112
+                throw new InvalidFolderException("folder $folder does not exist.");
113 113
             }
114 114
             $this->folders[] = $folder;
115 115
         }
Please login to merge, or discard this patch.
src/Loaders/MessagesCatalogue.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
     protected function loadTexts(): void
30 30
     {
31
-        if (count($this->folders) === 0) {
31
+        if(count($this->folders) === 0) {
32 32
             throw new FolderNotSetException("Folder for translations was not set.");
33 33
         }
34 34
         $this->resources = $texts = [];
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
         $files = Finder::findFiles($filename)
37 37
             ->from(...$this->folders);
38 38
         /** @var \SplFileInfo $file */
39
-        foreach ($files as $file) {
39
+        foreach($files as $file) {
40 40
             $texts = array_merge($texts, $this->parseFile($file->getPathname()));
41
-            if (isset($texts["__resources"])) {
41
+            if(isset($texts["__resources"])) {
42 42
                 $this->resources = array_merge($this->resources, $texts["__resources"]);
43 43
                 unset($texts["__resources"]);
44 44
             } else {
45 45
                 /** @var string[] $domains */
46 46
                 $domains = array_keys($texts);
47
-                foreach ($domains as $domain) {
47
+                foreach($domains as $domain) {
48 48
                     $this->addResource($file->getPathname(), $domain);
49 49
                 }
50 50
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@
 block discarded – undo
12 12
  *
13 13
  * @author Jakub Konečný
14 14
  */
15
-final class MessagesCatalogue extends FileLoader
16
-{
15
+final class MessagesCatalogue extends FileLoader {
17 16
     protected string $extension = "php";
18 17
 
19 18
     protected function parseFile(string $filename): array
Please login to merge, or discard this patch.
src/Loaders/JsonLoader.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
     protected function parseFile(string $filename): array
23 23
     {
24 24
         $content = file_get_contents($filename);
25
-        if ($content === false) {
25
+        if($content === false) {
26 26
             throw new \RuntimeException("File $filename does not exist or cannot be read.");
27 27
         }
28 28
         return Json::decode($content, Json::FORCE_ARRAY);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@
 block discarded – undo
11 11
  *
12 12
  * @author Jakub Konečný
13 13
  */
14
-final class JsonLoader extends FileLoader
15
-{
14
+final class JsonLoader extends FileLoader {
16 15
     protected string $extension = "json";
17 16
 
18 17
     /**
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     {
24 24
         $content = file_get_contents($filename);
25 25
         if ($content === false) {
26
-            throw new \RuntimeException("File $filename does not exist or cannot be read.");
26
+            throw new \RuntimeException("file $filename does not exist or cannot be read.");
27 27
         }
28 28
         return Json::decode($content, Json::FORCE_ARRAY);
29 29
     }
Please login to merge, or discard this patch.
src/Loaders/NeonLoader.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
     protected function parseFile(string $filename): array
22 22
     {
23 23
         $content = file_get_contents($filename);
24
-        if ($content === false) {
24
+        if($content === false) {
25 25
             throw new \RuntimeException("File $filename does not exist or cannot be read.");
26 26
         }
27 27
         return Neon::decode($content);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@
 block discarded – undo
11 11
  *
12 12
  * @author Jakub Konečný
13 13
  */
14
-final class NeonLoader extends FileLoader
15
-{
14
+final class NeonLoader extends FileLoader {
16 15
     protected string $extension = "neon";
17 16
 
18 17
     /**
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
     {
23 23
         $content = file_get_contents($filename);
24 24
         if ($content === false) {
25
-            throw new \RuntimeException("File $filename does not exist or cannot be read.");
25
+            throw new \RuntimeException("file $filename does not exist or cannot be read.");
26 26
         }
27 27
         return Neon::decode($content);
28 28
     }
Please login to merge, or discard this patch.
src/Loader.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@
 block discarded – undo
8 8
  *
9 9
  * @author Jakub Konečný
10 10
  */
11
-interface Loader
12
-{
11
+interface Loader {
13 12
     public function getLang(): string;
14 13
     public function setLang(string $lang): void;
15 14
     public function getDefaultLang(): string;
Please login to merge, or discard this patch.
src/Bridges/NetteDI/ITranslationProvider.php 2 patches
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\Bridges\NetteDI;
5 5
 
6
-if (false) { // @phpstan-ignore if.alwaysFalse
6
+if(false) { // @phpstan-ignore if.alwaysFalse
7 7
     /** @deprecated Use TranslationProvider */
8 8
     interface ITranslationProvider extends TranslationProvider
9 9
     {
10 10
     }
11
-} elseif (!interface_exists(ITranslationProvider::class)) {
11
+} elseif(!interface_exists(ITranslationProvider::class)) {
12 12
     class_alias(TranslationProvider::class, ITranslationProvider::class);
13 13
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,10 +3,10 @@
 block discarded – undo
3 3
 
4 4
 namespace Nexendrie\Translation\Bridges\NetteDI;
5 5
 
6
-if (false) { // @phpstan-ignore if.alwaysFalse
6
+if (false) {
7
+// @phpstan-ignore if.alwaysFalse
7 8
     /** @deprecated Use TranslationProvider */
8
-    interface ITranslationProvider extends TranslationProvider
9
-    {
9
+    interface ITranslationProvider extends TranslationProvider {
10 10
     }
11 11
 } elseif (!interface_exists(ITranslationProvider::class)) {
12 12
     class_alias(TranslationProvider::class, ITranslationProvider::class);
Please login to merge, or discard this patch.