@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Nexendrie\Translation\Bridges\NetteApplication; |
| 5 | 5 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * Resolve language |
| 41 | 41 | */ |
| 42 | - public function resolve(): ?string { |
|
| 42 | + public function resolve(): ? string { |
|
| 43 | 43 | if(!is_null($this->request)) { |
| 44 | 44 | return $this->request->getParameter($this->param); |
| 45 | 45 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | public function onRequest(Application $application, Request $request): void { |
| 32 | 32 | $locale = $request->getParameter($this->param); |
| 33 | - if($request->method === Request::FORWARD AND is_null($locale)) { |
|
| 33 | + if($request->method === Request::FORWARD and is_null($locale)) { |
|
| 34 | 34 | return; |
| 35 | 35 | } |
| 36 | 36 | $this->request = $request; |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | public function setFolders(array $folders) { |
| 82 | 82 | foreach($folders as $folder) { |
| 83 | 83 | if(!is_dir($folder)) { |
| 84 | - throw new InvalidFolderException("Folder $folder does not exist."); |
|
| 84 | + throw new InvalidFolderException("folder $folder does not exist."); |
|
| 85 | 85 | } |
| 86 | 86 | $this->folders[] = $folder; |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | protected function addResource(string $filename, string $domain): void { |
| 91 | - if(!isset($this->resources[$domain]) OR !in_array($filename, $this->resources[$domain])) { |
|
| 91 | + if(!isset($this->resources[$domain]) or !in_array($filename, $this->resources[$domain])) { |
|
| 92 | 92 | $this->resources[$domain][] = $filename; |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $lang = []; |
| 120 | 120 | $filename = "$name.$this->lang.$extension"; |
| 121 | 121 | $filename = str_replace($defaultFilename, $filename, $file->getPathname()); |
| 122 | - if($this->lang != $defaultLang AND is_file($filename)) { |
|
| 122 | + if($this->lang != $defaultLang and is_file($filename)) { |
|
| 123 | 123 | $lang = $this->parseFile($filename); |
| 124 | 124 | $this->addResource($filename, $name); |
| 125 | 125 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Nexendrie\Translation\Resolvers; |
| 5 | 5 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $this->section = $session->getSection(get_class($this)); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function getLang(): ?string { |
|
| 38 | + public function getLang(): ? string { |
|
| 39 | 39 | if(empty($this->section->{$this->varName})) { |
| 40 | 40 | return NULL; |
| 41 | 41 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * Resolve language |
| 59 | 59 | */ |
| 60 | - public function resolve(): ?string { |
|
| 60 | + public function resolve(): ? string { |
|
| 61 | 61 | return $this->getLang(); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Nexendrie\Translation\Resolvers; |
| 5 | 5 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return NULL |
| 20 | 20 | */ |
| 21 | - public function resolve(): ?string { |
|
| 21 | + public function resolve(): ? string { |
|
| 22 | 22 | return NULL; |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Nexendrie\Translation\Resolvers; |
| 5 | 5 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $this[] = $resolver; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function resolve(): ?string { |
|
| 24 | + public function resolve(): ? string { |
|
| 25 | 25 | foreach($this as $resolver) { |
| 26 | 26 | $lang = $resolver->resolve(); |
| 27 | 27 | if(!is_null($lang)) { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Nexendrie\Translation\Resolvers; |
| 5 | 5 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | /** @var string|NULL */ |
| 17 | 17 | protected $lang = NULL; |
| 18 | 18 | |
| 19 | - public function getLang(): ?string { |
|
| 19 | + public function getLang(): ? string { |
|
| 20 | 20 | return $this->lang; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $this->lang = $lang; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function resolve(): ?string { |
|
| 27 | + public function resolve(): ? string { |
|
| 28 | 28 | return $this->getLang(); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Nexendrie\Translation\Resolvers; |
| 5 | 5 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * Taken from Nette\Http\Request::detectLanguage() |
| 39 | 39 | * @author David Grudl |
| 40 | 40 | */ |
| 41 | - public function resolve(): ?string { |
|
| 41 | + public function resolve(): ? string { |
|
| 42 | 42 | if(is_null($this->loader)) { |
| 43 | 43 | throw new LoaderNotSetException("Loader is not available, cannot detect possible languages."); |
| 44 | 44 | } |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | if(is_null($header)) { |
| 48 | 48 | return NULL; |
| 49 | 49 | } |
| 50 | - $s = strtolower($header); // case insensitive |
|
| 51 | - $s = strtr($s, '_', '-'); // cs_CZ means cs-CZ |
|
| 52 | - rsort($langs); // first more specific |
|
| 50 | + $s = strtolower($header); // case insensitive |
|
| 51 | + $s = strtr($s, '_', '-'); // cs_CZ means cs-CZ |
|
| 52 | + rsort($langs); // first more specific |
|
| 53 | 53 | $pattern = ')(?:-[^\s,;=]+)?\s*(?:;\s*q=([0-9.]+))?#'; |
| 54 | 54 | preg_match_all('#(' . implode('|', $langs) . $pattern, $s, $matches); |
| 55 | 55 | if(!$matches[0]) { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Nexendrie\Translation\Resolvers; |
| 5 | 5 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** @var string */ |
| 18 | 18 | protected $varName = "TRANSLATOR_LANGUAGE"; |
| 19 | 19 | |
| 20 | - public function getLang(): ?string { |
|
| 20 | + public function getLang(): ? string { |
|
| 21 | 21 | $lang = getenv($this->varName); |
| 22 | 22 | if($lang) { |
| 23 | 23 | return $lang; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $this->varName = $varName; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function resolve(): ?string { |
|
| 40 | + public function resolve(): ? string { |
|
| 41 | 41 | return $this->getLang(); |
| 42 | 42 | } |
| 43 | 43 | } |