Passed
Push — master ( e878e5...5274cf )
by Radovan
02:02
created
src/Bridges/TranslatorExtension.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -58,8 +58,9 @@  discard block
 block discarded – undo
58 58
 		// Create temp directory
59 59
 		if (!is_dir($this->tempDir)) {
60 60
 			@mkdir($this->tempDir, 0777, true);
61
-			if (!is_dir($this->tempDir))
62
-				throw new PathInvalidException("Failed to create temp dir on path '{$this->tempDir}'.");
61
+			if (!is_dir($this->tempDir)) {
62
+							throw new PathInvalidException("Failed to create temp dir on path '{$this->tempDir}'.");
63
+			}
63 64
 		}
64 65
 	}
65 66
 
@@ -85,12 +86,14 @@  discard block
 block discarded – undo
85 86
 		$builder = $this->getContainerBuilder();
86 87
 
87 88
 		// Panel if in debug
88
-		if ($config->debugger)
89
-			$builder->addDefinition($this->prefix('diagnostics'))->setFactory(Panel::class);
89
+		if ($config->debugger) {
90
+					$builder->addDefinition($this->prefix('diagnostics'))->setFactory(Panel::class);
91
+		}
90 92
 
91 93
 		// Resolver if configured
92
-		if ($config->resolver)
93
-			$builder->addDefinition($this->prefix('languageResolver'))->setFactory(LangResolver::class, [$config->languages]);
94
+		if ($config->resolver) {
95
+					$builder->addDefinition($this->prefix('languageResolver'))->setFactory(LangResolver::class, [$config->languages]);
96
+		}
94 97
 
95 98
 		// Provider
96 99
 		$builder->addDefinition($this->prefix('translatorProvider'))->setFactory(TranslatorProvider::class, [$config->languages, $config->prototype]);
@@ -124,12 +127,14 @@  discard block
 block discarded – undo
124 127
 			$catalogue = $builder->getDefinition($this->prefix($locale . 'Catalogue'));
125 128
 
126 129
 			// Enable debug mode for catalogue
127
-			if ($config->debugger)
128
-				$catalogue->addSetup('setDebugMode', [true]);
130
+			if ($config->debugger) {
131
+							$catalogue->addSetup('setDebugMode', [true]);
132
+			}
129 133
 
130 134
 			// Add resource files
131
-			foreach ($this->getCatalogueResources($locale) as $file)
132
-				$catalogue->addSetup('addFile', [$file->getPathname()]);
135
+			foreach ($this->getCatalogueResources($locale) as $file) {
136
+							$catalogue->addSetup('addFile', [$file->getPathname()]);
137
+			}
133 138
 
134 139
 			// Add catalogue to provider
135 140
 			$provider->addSetup('addCatalogue', [$locale, $catalogue]);
Please login to merge, or discard this patch.
src/Bridges/TranslatorProvider.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,8 +69,9 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function getTranslator(string $locale): ITranslator {
71 71
 		$locale = strtolower($locale);
72
-		if (!isset($this->translators[$locale]))
73
-			$this->translators[$locale] = $this->createTranslator($locale);
72
+		if (!isset($this->translators[$locale])) {
73
+					$this->translators[$locale] = $this->createTranslator($locale);
74
+		}
74 75
 		return $this->translators[$locale];
75 76
 	}
76 77
 
@@ -80,8 +81,9 @@  discard block
 block discarded – undo
80 81
 	 * @throws \Throwable
81 82
 	 */
82 83
 	protected function createTranslator(string $locale): ITranslator {
83
-		if (!isset($this->catalogues[$locale]))
84
-			throw new TranslatorException("Language {$locale} requested, but corresponding catalogue missing.");
84
+		if (!isset($this->catalogues[$locale])) {
85
+					throw new TranslatorException("Language {$locale} requested, but corresponding catalogue missing.");
86
+		}
85 87
 
86 88
 		$translator = new Translator($this->catalogues[$locale]->compile(), $this->diagnostics);
87 89
 		return new $this->prototype($translator);
Please login to merge, or discard this patch.
src/Bridges/TranslatorAwarePresenter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@
 block discarded – undo
36 36
 	 * @param TranslatorProvider $provider
37 37
 	 */
38 38
 	public function injectTranslator(TranslatorProvider $provider) {
39
-		$this->onStartup[] = function () use ($provider) {
39
+		$this->onStartup[] = function() use ($provider) {
40 40
 			$this->translator = $provider->getTranslator($this->lang);
41 41
 		};
42
-		$this->onRender[] = function () {
42
+		$this->onRender[] = function() {
43 43
 			$this->template->setTranslator($this->translator);
44 44
 		};
45 45
 	}
Please login to merge, or discard this patch.
src/Translator.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 	 * @return string
42 42
 	 */
43 43
 	function translate($message, ...$parameters): string {
44
-		if($message instanceof Html)
44
+		if ($message instanceof Html)
45 45
 			return (string) $message;
46 46
 		return $this->translator->translate($message, ...$parameters);
47 47
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,8 +41,9 @@
 block discarded – undo
41 41
 	 * @return string
42 42
 	 */
43 43
 	function translate($message, ...$parameters): string {
44
-		if($message instanceof Html)
45
-			return (string) $message;
44
+		if($message instanceof Html) {
45
+					return (string) $message;
46
+		}
46 47
 		return $this->translator->translate($message, ...$parameters);
47 48
 	}
48 49
 }
Please login to merge, or discard this patch.
src/Diagnostics/Panel.php 1 patch
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -27,8 +27,9 @@  discard block
 block discarded – undo
27 27
 	 * Panel constructor.
28 28
 	 */
29 29
 	public function __construct() {
30
-		if (class_exists(Debugger::class))
31
-			Debugger::getBar()->addPanel($this, 'bckp.localization');
30
+		if (class_exists(Debugger::class)) {
31
+					Debugger::getBar()->addPanel($this, 'bckp.localization');
32
+		}
32 33
 	}
33 34
 
34 35
 	/**
@@ -60,10 +61,18 @@  discard block
 block discarded – undo
60 61
 			$u .= '<tr><td>' . $h($message) . '</td></tr>';
61 62
 		}
62 63
 
63
-		if ($e || $u) $return = '<h1>' . strtoupper($this->getLocale()) . ' language</h1><div class="nette-inner bckp-translation">';
64
-		if ($e) $return .= '<h2>Errors: ' . count($unique) . '</h2><table class="tracy-sortable">' . $e . '</table>';
65
-		if ($u) $return .= '<h2>Missing: ' . count($untranslated) . '</h2><table class="tracy-sortable">' . $u . '</table>';
66
-		if ($e || $u) $return .= '</div>';
64
+		if ($e || $u) {
65
+			$return = '<h1>' . strtoupper($this->getLocale()) . ' language</h1><div class="nette-inner bckp-translation">';
66
+		}
67
+		if ($e) {
68
+			$return .= '<h2>Errors: ' . count($unique) . '</h2><table class="tracy-sortable">' . $e . '</table>';
69
+		}
70
+		if ($u) {
71
+			$return .= '<h2>Missing: ' . count($untranslated) . '</h2><table class="tracy-sortable">' . $u . '</table>';
72
+		}
73
+		if ($e || $u) {
74
+			$return .= '</div>';
75
+		}
67 76
 		return $return;
68 77
 	}
69 78
 
@@ -72,10 +81,12 @@  discard block
 block discarded – undo
72 81
 	 * @return string
73 82
 	 */
74 83
 	protected function getErrors(int $errors = 0): string {
75
-		if (!$errors)
76
-			return '';
77
-		if ($errors === 1)
78
-			return '1 error';
84
+		if (!$errors) {
85
+					return '';
86
+		}
87
+		if ($errors === 1) {
88
+					return '1 error';
89
+		}
79 90
 		return $errors . ' errors';
80 91
 	}
81 92
 }
Please login to merge, or discard this patch.
src/CompatibilityTranslator.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,11 +40,13 @@
 block discarded – undo
40 40
 	 * @return string
41 41
 	 */
42 42
 	public function translate($message, ...$parameters): string {
43
-		if (empty($parameters))
44
-			return $this->translator->translate($message);
43
+		if (empty($parameters)) {
44
+					return $this->translator->translate($message);
45
+		}
45 46
 
46
-		if (is_array($parameters[0]))
47
-			return $this->translator->translate($message, ...$parameters[0]);
47
+		if (is_array($parameters[0])) {
48
+					return $this->translator->translate($message, ...$parameters[0]);
49
+		}
48 50
 
49 51
 		if (is_numeric($parameters[0])) {
50 52
 			$count = $parameters[0];
Please login to merge, or discard this patch.