Test Failed
Pull Request — master (#952)
by Maxim
15:38 queued 06:10
created
src/Translator/src/Config/TranslatorConfig.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
     public function getLocaleDirectory(string $locale): string
79 79
     {
80
-        return $this->getLocalesDirectory() . $locale . '/';
80
+        return $this->getLocalesDirectory().$locale.'/';
81 81
     }
82 82
 
83 83
     /**
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
     public function resolveDomain(string $bundle): string
87 87
     {
88 88
         $bundle = \strtolower(\str_replace(['/', '\\'], '-', $bundle));
89
-        $domains = (array) ($this->config['domains'] ?? []);
89
+        $domains = (array)($this->config['domains'] ?? []);
90 90
 
91
-        foreach ($domains as $domain => $patterns) {
92
-            foreach ($patterns as $pattern) {
93
-                if ($this->matcher->matches($bundle, $pattern)) {
91
+        foreach ($domains as $domain => $patterns){
92
+            foreach ($patterns as $pattern){
93
+                if ($this->matcher->matches($bundle, $pattern)){
94 94
                     return $domain;
95 95
                 }
96 96
             }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -88,9 +88,12 @@
 block discarded – undo
88 88
         $bundle = \strtolower(\str_replace(['/', '\\'], '-', $bundle));
89 89
         $domains = (array) ($this->config['domains'] ?? []);
90 90
 
91
-        foreach ($domains as $domain => $patterns) {
92
-            foreach ($patterns as $pattern) {
93
-                if ($this->matcher->matches($bundle, $pattern)) {
91
+        foreach ($domains as $domain => $patterns)
92
+        {
93
+            foreach ($patterns as $pattern)
94
+            {
95
+                if ($this->matcher->matches($bundle, $pattern))
96
+                {
94 97
                     return $domain;
95 98
                 }
96 99
             }
Please login to merge, or discard this patch.
src/Translator/src/Matcher.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
         return match (true) {
25 25
             $string === $pattern => true,
26 26
             !$this->isPattern($pattern) => false,
27
-            default => (bool) \preg_match($this->getRegex($pattern), $string)
27
+            default => (bool)\preg_match($this->getRegex($pattern), $string)
28 28
         };
29 29
     }
30 30
 
Please login to merge, or discard this patch.
src/Translator/src/Exception/LocaleException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Translator/src/Traits/TranslatorTrait.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
      */
34 34
     protected function say(string $string, array $options = [], string $bundle = null): string
35 35
     {
36
-        if (Translator::isMessage($string)) {
36
+        if (Translator::isMessage($string)){
37 37
             //Cut [[ and ]]
38 38
             $string = \substr($string, 2, -2);
39 39
         }
40 40
 
41 41
         $container = ContainerScope::getContainer();
42
-        if (empty($container) || !$container->has(TranslatorInterface::class)) {
42
+        if (empty($container) || !$container->has(TranslatorInterface::class)){
43 43
             return Translator::interpolate($string, $options);
44 44
         }
45 45
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
          */
49 49
         $translator = $container->get(TranslatorInterface::class);
50 50
 
51
-        if (\is_null($bundle)) {
51
+        if (\is_null($bundle)){
52 52
             $bundle = $translator->getDomain(static::class);
53 53
         }
54 54
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,13 +33,15 @@  discard block
 block discarded – undo
33 33
      */
34 34
     protected function say(string $string, array $options = [], string $bundle = null): string
35 35
     {
36
-        if (Translator::isMessage($string)) {
36
+        if (Translator::isMessage($string))
37
+        {
37 38
             //Cut [[ and ]]
38 39
             $string = \substr($string, 2, -2);
39 40
         }
40 41
 
41 42
         $container = ContainerScope::getContainer();
42
-        if (empty($container) || !$container->has(TranslatorInterface::class)) {
43
+        if (empty($container) || !$container->has(TranslatorInterface::class))
44
+        {
43 45
             return Translator::interpolate($string, $options);
44 46
         }
45 47
 
@@ -48,7 +50,8 @@  discard block
 block discarded – undo
48 50
          */
49 51
         $translator = $container->get(TranslatorInterface::class);
50 52
 
51
-        if (\is_null($bundle)) {
53
+        if (\is_null($bundle))
54
+        {
52 55
             $bundle = $translator->getDomain(static::class);
53 56
         }
54 57
 
Please login to merge, or discard this patch.
src/Translator/src/Event/LocaleUpdated.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,6 +8,6 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct(
10 10
         public readonly string $locale,
11
-    ) {
11
+    ){
12 12
     }
13 13
 }
Please login to merge, or discard this patch.
src/Translator/src/helpers.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use Spiral\Translator\Exception\TranslatorException;
8 8
 use Spiral\Translator\TranslatorInterface;
9 9
 
10
-if (!\function_exists('l')) {
10
+if (!\function_exists('l')){
11 11
     /**
12 12
      * Translate message using default or specific bundle name.
13 13
      *
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     {
23 23
         /** @psalm-suppress InternalMethod */
24 24
         $container = ContainerScope::getContainer();
25
-        if ($container === null || !$container->has(TranslatorInterface::class)) {
25
+        if ($container === null || !$container->has(TranslatorInterface::class)){
26 26
             throw new ScopeException(
27 27
                 '`TranslatorInterface` binding is missing or container scope is not set'
28 28
             );
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     }
36 36
 }
37 37
 
38
-if (!\function_exists('p')) {
38
+if (!\function_exists('p')){
39 39
     /**
40 40
      * Pluralize string using language pluralization options and specified numeric value.
41 41
      *
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     {
52 52
         /** @psalm-suppress InternalMethod */
53 53
         $container = ContainerScope::getContainer();
54
-        if (empty($container) || !$container->has(TranslatorInterface::class)) {
54
+        if (empty($container) || !$container->has(TranslatorInterface::class)){
55 55
             throw new ScopeException(
56 56
                 '`TranslatorInterface` binding is missing or container scope is not set'
57 57
             );
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,7 +7,8 @@  discard block
 block discarded – undo
7 7
 use Spiral\Translator\Exception\TranslatorException;
8 8
 use Spiral\Translator\TranslatorInterface;
9 9
 
10
-if (!\function_exists('l')) {
10
+if (!\function_exists('l'))
11
+{
11 12
     /**
12 13
      * Translate message using default or specific bundle name.
13 14
      *
@@ -22,7 +23,8 @@  discard block
 block discarded – undo
22 23
     {
23 24
         /** @psalm-suppress InternalMethod */
24 25
         $container = ContainerScope::getContainer();
25
-        if ($container === null || !$container->has(TranslatorInterface::class)) {
26
+        if ($container === null || !$container->has(TranslatorInterface::class))
27
+        {
26 28
             throw new ScopeException(
27 29
                 '`TranslatorInterface` binding is missing or container scope is not set'
28 30
             );
@@ -35,7 +37,8 @@  discard block
 block discarded – undo
35 37
     }
36 38
 }
37 39
 
38
-if (!\function_exists('p')) {
40
+if (!\function_exists('p'))
41
+{
39 42
     /**
40 43
      * Pluralize string using language pluralization options and specified numeric value.
41 44
      *
@@ -51,7 +54,8 @@  discard block
 block discarded – undo
51 54
     {
52 55
         /** @psalm-suppress InternalMethod */
53 56
         $container = ContainerScope::getContainer();
54
-        if (empty($container) || !$container->has(TranslatorInterface::class)) {
57
+        if (empty($container) || !$container->has(TranslatorInterface::class))
58
+        {
55 59
             throw new ScopeException(
56 60
                 '`TranslatorInterface` binding is missing or container scope is not set'
57 61
             );
Please login to merge, or discard this patch.
src/Translator/src/Catalogue/RuntimeLoader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 
32 32
     public function loadCatalogue(string $locale): CatalogueInterface
33 33
     {
34
-        if (!$this->hasLocale($locale)) {
34
+        if (!$this->hasLocale($locale)){
35 35
             throw new LocaleException($locale);
36 36
         }
37 37
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@
 block discarded – undo
31 31
 
32 32
     public function loadCatalogue(string $locale): CatalogueInterface
33 33
     {
34
-        if (!$this->hasLocale($locale)) {
34
+        if (!$this->hasLocale($locale))
35
+        {
35 36
             throw new LocaleException($locale);
36 37
         }
37 38
 
Please login to merge, or discard this patch.
src/Translator/src/Catalogue/CatalogueManager.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,18 +24,18 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,12 +30,14 @@  discard block
 block discarded – undo
30 30
 
31 31
     public function getLocales(): array
32 32
     {
33
-        if ($this->locales !== []) {
33
+        if ($this->locales !== [])
34
+        {
34 35
             return $this->locales;
35 36
         }
36 37
 
37 38
         $this->locales = (array)$this->cache->getLocales();
38
-        if ($this->locales === []) {
39
+        if ($this->locales === [])
40
+        {
39 41
             $this->locales = $this->loader->getLocales();
40 42
             $this->cache->setLocales($this->locales);
41 43
         }
@@ -45,14 +47,18 @@  discard block
 block discarded – undo
45 47
 
46 48
     public function load(string $locale): CatalogueInterface
47 49
     {
48
-        if (isset($this->catalogues[$locale])) {
50
+        if (isset($this->catalogues[$locale]))
51
+        {
49 52
             return $this->catalogues[$locale];
50 53
         }
51 54
 
52 55
         $data = (array)$this->cache->loadLocale($locale);
53
-        if (!empty($data)) {
56
+        if (!empty($data))
57
+        {
54 58
             $this->catalogues[$locale] = new Catalogue($locale, $data);
55
-        } else {
59
+        }
60
+        else
61
+        {
56 62
             $this->catalogues[$locale] = $this->loader->loadCatalogue($locale);
57 63
         }
58 64
 
@@ -80,7 +86,8 @@  discard block
 block discarded – undo
80 86
     public function reset(): void
81 87
     {
82 88
         $this->cache->setLocales(null);
83
-        foreach ($this->getLocales() as $locale) {
89
+        foreach ($this->getLocales() as $locale)
90
+        {
84 91
             $this->cache->saveLocale($locale, null);
85 92
         }
86 93
 
Please login to merge, or discard this patch.
src/Translator/src/Catalogue/CatalogueLoader.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
     public function __construct(
18 18
         private readonly TranslatorConfig $config
19
-    ) {
19
+    ){
20 20
     }
21 21
 
22 22
     public function hasLocale(string $locale): bool
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
     public function getLocales(): array
30 30
     {
31
-        if (!\is_dir($this->config->getLocalesDirectory())) {
31
+        if (!\is_dir($this->config->getLocalesDirectory())){
32 32
             return [];
33 33
         }
34 34
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
         $locales = [];
39 39
 
40
-        foreach ($finder->directories() as $directory) {
40
+        foreach ($finder->directories() as $directory){
41 41
             $locales[] = $directory->getFilename();
42 42
         }
43 43
 
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
         $locale = \preg_replace('/[^a-zA-Z_]/', '', \mb_strtolower($locale));
50 50
         $catalogue = new Catalogue($locale);
51 51
 
52
-        if (!$this->hasLocale($locale)) {
52
+        if (!$this->hasLocale($locale)){
53 53
             return $catalogue;
54 54
         }
55 55
 
56 56
         $finder = new Finder();
57 57
         $finder->in($this->config->getLocaleDirectory($locale));
58 58
 
59
-        foreach ($finder->getIterator() as $file) {
59
+        foreach ($finder->getIterator() as $file){
60 60
             $this->getLogger()->info(
61 61
                 \sprintf(
62 62
                     "found locale domain file '%s'",
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             //Per application agreement domain name must present in filename
69 69
             $domain = \strstr($file->getFilename(), '.', true);
70 70
 
71
-            if (!$this->config->hasLoader($file->getExtension())) {
71
+            if (!$this->config->hasLoader($file->getExtension())){
72 72
                 $this->getLogger()->warning(
73 73
                     \sprintf(
74 74
                         "unable to load domain file '%s', no loader found",
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,7 +28,8 @@  discard block
 block discarded – undo
28 28
 
29 29
     public function getLocales(): array
30 30
     {
31
-        if (!\is_dir($this->config->getLocalesDirectory())) {
31
+        if (!\is_dir($this->config->getLocalesDirectory()))
32
+        {
32 33
             return [];
33 34
         }
34 35
 
@@ -37,7 +38,8 @@  discard block
 block discarded – undo
37 38
 
38 39
         $locales = [];
39 40
 
40
-        foreach ($finder->directories() as $directory) {
41
+        foreach ($finder->directories() as $directory)
42
+        {
41 43
             $locales[] = $directory->getFilename();
42 44
         }
43 45
 
@@ -49,14 +51,16 @@  discard block
 block discarded – undo
49 51
         $locale = \preg_replace('/[^a-zA-Z_]/', '', \mb_strtolower($locale));
50 52
         $catalogue = new Catalogue($locale);
51 53
 
52
-        if (!$this->hasLocale($locale)) {
54
+        if (!$this->hasLocale($locale))
55
+        {
53 56
             return $catalogue;
54 57
         }
55 58
 
56 59
         $finder = new Finder();
57 60
         $finder->in($this->config->getLocaleDirectory($locale));
58 61
 
59
-        foreach ($finder->getIterator() as $file) {
62
+        foreach ($finder->getIterator() as $file)
63
+        {
60 64
             $this->getLogger()->info(
61 65
                 \sprintf(
62 66
                     "found locale domain file '%s'",
@@ -68,7 +72,8 @@  discard block
 block discarded – undo
68 72
             //Per application agreement domain name must present in filename
69 73
             $domain = \strstr($file->getFilename(), '.', true);
70 74
 
71
-            if (!$this->config->hasLoader($file->getExtension())) {
75
+            if (!$this->config->hasLoader($file->getExtension()))
76
+            {
72 77
                 $this->getLogger()->warning(
73 78
                     \sprintf(
74 79
                         "unable to load domain file '%s', no loader found",
Please login to merge, or discard this patch.