@@ -36,11 +36,11 @@ |
||
36 | 36 | */ |
37 | 37 | public function loadFile(string $section, string $filename): array |
38 | 38 | { |
39 | - try { |
|
39 | + try{ |
|
40 | 40 | return ContainerScope::runScope($this->container, function () use ($filename) { |
41 | 41 | return (require $filename); |
42 | 42 | }); |
43 | - } catch (\Throwable $e) { |
|
43 | + }catch (\Throwable $e){ |
|
44 | 44 | throw new LoaderException($e->getMessage(), $e->getCode(), $e); |
45 | 45 | } |
46 | 46 | } |
@@ -36,11 +36,15 @@ |
||
36 | 36 | */ |
37 | 37 | public function loadFile(string $section, string $filename): array |
38 | 38 | { |
39 | - try { |
|
40 | - return ContainerScope::runScope($this->container, function () use ($filename) { |
|
39 | + try |
|
40 | + { |
|
41 | + return ContainerScope::runScope($this->container, function () use ($filename) |
|
42 | + { |
|
41 | 43 | return (require $filename); |
42 | 44 | }); |
43 | - } catch (\Throwable $e) { |
|
45 | + } |
|
46 | + catch (\Throwable $e) |
|
47 | + { |
|
44 | 48 | throw new LoaderException($e->getMessage(), $e->getCode(), $e); |
45 | 49 | } |
46 | 50 | } |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __construct(string $key) |
39 | 39 | { |
40 | - try { |
|
40 | + try{ |
|
41 | 41 | $this->key = Key::loadFromAsciiSafeString($key); |
42 | - } catch (CryptoException $e) { |
|
42 | + }catch (CryptoException $e){ |
|
43 | 43 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
44 | 44 | } |
45 | 45 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | public function withKey(string $key): EncrypterInterface |
51 | 51 | { |
52 | 52 | $encrypter = clone $this; |
53 | - try { |
|
53 | + try{ |
|
54 | 54 | $encrypter->key = Key::loadFromAsciiSafeString($key); |
55 | - } catch (CryptoException $e) { |
|
55 | + }catch (CryptoException $e){ |
|
56 | 56 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
57 | 57 | } |
58 | 58 | |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function getKey(): string |
66 | 66 | { |
67 | - try { |
|
67 | + try{ |
|
68 | 68 | return $this->key->saveToAsciiSafeString(); |
69 | - } catch (EnvironmentIsBrokenException $e) { |
|
69 | + }catch (EnvironmentIsBrokenException $e){ |
|
70 | 70 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
71 | 71 | } |
72 | 72 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | { |
81 | 81 | $packed = json_encode($data); |
82 | 82 | |
83 | - try { |
|
83 | + try{ |
|
84 | 84 | return base64_encode(Crypto::Encrypt($packed, $this->key)); |
85 | - } catch (\Throwable $e) { |
|
85 | + }catch (\Throwable $e){ |
|
86 | 86 | throw new EncryptException($e->getMessage(), $e->getCode(), $e); |
87 | 87 | } |
88 | 88 | } |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function decrypt(string $payload) |
96 | 96 | { |
97 | - try { |
|
97 | + try{ |
|
98 | 98 | $result = Crypto::Decrypt( |
99 | 99 | base64_decode($payload), |
100 | 100 | $this->key |
101 | 101 | ); |
102 | 102 | |
103 | 103 | return json_decode($result, true); |
104 | - } catch (\Throwable $e) { |
|
104 | + }catch (\Throwable $e){ |
|
105 | 105 | throw new DecryptException($e->getMessage(), $e->getCode(), $e); |
106 | 106 | } |
107 | 107 | } |
@@ -37,9 +37,12 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __construct(string $key) |
39 | 39 | { |
40 | - try { |
|
40 | + try |
|
41 | + { |
|
41 | 42 | $this->key = Key::loadFromAsciiSafeString($key); |
42 | - } catch (CryptoException $e) { |
|
43 | + } |
|
44 | + catch (CryptoException $e) |
|
45 | + { |
|
43 | 46 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
44 | 47 | } |
45 | 48 | } |
@@ -50,9 +53,12 @@ discard block |
||
50 | 53 | public function withKey(string $key): EncrypterInterface |
51 | 54 | { |
52 | 55 | $encrypter = clone $this; |
53 | - try { |
|
56 | + try |
|
57 | + { |
|
54 | 58 | $encrypter->key = Key::loadFromAsciiSafeString($key); |
55 | - } catch (CryptoException $e) { |
|
59 | + } |
|
60 | + catch (CryptoException $e) |
|
61 | + { |
|
56 | 62 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
57 | 63 | } |
58 | 64 | |
@@ -64,9 +70,12 @@ discard block |
||
64 | 70 | */ |
65 | 71 | public function getKey(): string |
66 | 72 | { |
67 | - try { |
|
73 | + try |
|
74 | + { |
|
68 | 75 | return $this->key->saveToAsciiSafeString(); |
69 | - } catch (EnvironmentIsBrokenException $e) { |
|
76 | + } |
|
77 | + catch (EnvironmentIsBrokenException $e) |
|
78 | + { |
|
70 | 79 | throw new EncrypterException($e->getMessage(), $e->getCode(), $e); |
71 | 80 | } |
72 | 81 | } |
@@ -80,9 +89,12 @@ discard block |
||
80 | 89 | { |
81 | 90 | $packed = json_encode($data); |
82 | 91 | |
83 | - try { |
|
92 | + try |
|
93 | + { |
|
84 | 94 | return base64_encode(Crypto::Encrypt($packed, $this->key)); |
85 | - } catch (\Throwable $e) { |
|
95 | + } |
|
96 | + catch (\Throwable $e) |
|
97 | + { |
|
86 | 98 | throw new EncryptException($e->getMessage(), $e->getCode(), $e); |
87 | 99 | } |
88 | 100 | } |
@@ -94,14 +106,17 @@ discard block |
||
94 | 106 | */ |
95 | 107 | public function decrypt(string $payload) |
96 | 108 | { |
97 | - try { |
|
109 | + try |
|
110 | + { |
|
98 | 111 | $result = Crypto::Decrypt( |
99 | 112 | base64_decode($payload), |
100 | 113 | $this->key |
101 | 114 | ); |
102 | 115 | |
103 | 116 | return json_decode($result, true); |
104 | - } catch (\Throwable $e) { |
|
117 | + } |
|
118 | + catch (\Throwable $e) |
|
119 | + { |
|
105 | 120 | throw new DecryptException($e->getMessage(), $e->getCode(), $e); |
106 | 121 | } |
107 | 122 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @var string |
25 | 25 | */ |
26 | - protected $element = '%s%s' . Color::RESET; |
|
26 | + protected $element = '%s%s'.Color::RESET; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Set of styles associated with different dumping properties. |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function apply($element, string $type, string $context = ''): string |
64 | 64 | { |
65 | - if (!empty($style = $this->getStyle($type, $context))) { |
|
65 | + if (!empty($style = $this->getStyle($type, $context))){ |
|
66 | 66 | return sprintf($this->element, $style, $element); |
67 | 67 | } |
68 | 68 | |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | */ |
88 | 88 | private function getStyle(string $type, string $context): string |
89 | 89 | { |
90 | - if (isset($this->styles[$type][$context])) { |
|
90 | + if (isset($this->styles[$type][$context])){ |
|
91 | 91 | return $this->styles[$type][$context]; |
92 | 92 | } |
93 | 93 | |
94 | - if (isset($this->styles[$type]['common'])) { |
|
94 | + if (isset($this->styles[$type]['common'])){ |
|
95 | 95 | return $this->styles[$type]['common']; |
96 | 96 | } |
97 | 97 | |
98 | - if (isset($this->styles[$type]) && is_string($this->styles[$type])) { |
|
98 | + if (isset($this->styles[$type]) && is_string($this->styles[$type])){ |
|
99 | 99 | return $this->styles[$type]; |
100 | 100 | } |
101 | 101 |
@@ -56,33 +56,33 @@ |
||
56 | 56 | public function wrap(array $args): array |
57 | 57 | { |
58 | 58 | $result = []; |
59 | - foreach ($args as $arg) { |
|
59 | + foreach ($args as $arg){ |
|
60 | 60 | $display = $type = strtolower(gettype($arg)); |
61 | 61 | |
62 | - if (is_numeric($arg)) { |
|
62 | + if (is_numeric($arg)){ |
|
63 | 63 | $result[] = $this->r->apply($arg, 'value', $type); |
64 | 64 | continue; |
65 | - } elseif (is_bool($arg)) { |
|
65 | + } elseif (is_bool($arg)){ |
|
66 | 66 | $result[] = $this->r->apply($arg ? 'true' : 'false', 'value', $type); |
67 | 67 | continue; |
68 | - } elseif (is_null($arg)) { |
|
68 | + } elseif (is_null($arg)){ |
|
69 | 69 | $result[] = $this->r->apply('null', 'value', $type); |
70 | 70 | continue; |
71 | 71 | } |
72 | 72 | |
73 | - if (is_object($arg)) { |
|
73 | + if (is_object($arg)){ |
|
74 | 74 | $reflection = new \ReflectionClass($arg); |
75 | 75 | $display = sprintf('<span title="%s">%s</span>', $reflection->getName(), $reflection->getShortName()); |
76 | 76 | } |
77 | 77 | |
78 | 78 | $type = $this->r->apply($display, 'value', $type); |
79 | 79 | |
80 | - if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG) { |
|
80 | + if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG){ |
|
81 | 81 | $result[] = sprintf('<span>%s</span>', $type); |
82 | - } else { |
|
82 | + }else{ |
|
83 | 83 | $hash = is_object($arg) ? spl_object_hash($arg) : md5(json_encode($arg)); |
84 | 84 | |
85 | - if (!isset($this->values[$hash])) { |
|
85 | + if (!isset($this->values[$hash])){ |
|
86 | 86 | $this->values[$hash] = $this->dumper->dump($arg, Dumper::RETURN); |
87 | 87 | } |
88 | 88 |
@@ -56,33 +56,44 @@ |
||
56 | 56 | public function wrap(array $args): array |
57 | 57 | { |
58 | 58 | $result = []; |
59 | - foreach ($args as $arg) { |
|
59 | + foreach ($args as $arg) |
|
60 | + { |
|
60 | 61 | $display = $type = strtolower(gettype($arg)); |
61 | 62 | |
62 | - if (is_numeric($arg)) { |
|
63 | + if (is_numeric($arg)) |
|
64 | + { |
|
63 | 65 | $result[] = $this->r->apply($arg, 'value', $type); |
64 | 66 | continue; |
65 | - } elseif (is_bool($arg)) { |
|
67 | + } |
|
68 | + elseif (is_bool($arg)) |
|
69 | + { |
|
66 | 70 | $result[] = $this->r->apply($arg ? 'true' : 'false', 'value', $type); |
67 | 71 | continue; |
68 | - } elseif (is_null($arg)) { |
|
72 | + } |
|
73 | + elseif (is_null($arg)) |
|
74 | + { |
|
69 | 75 | $result[] = $this->r->apply('null', 'value', $type); |
70 | 76 | continue; |
71 | 77 | } |
72 | 78 | |
73 | - if (is_object($arg)) { |
|
79 | + if (is_object($arg)) |
|
80 | + { |
|
74 | 81 | $reflection = new \ReflectionClass($arg); |
75 | 82 | $display = sprintf('<span title="%s">%s</span>', $reflection->getName(), $reflection->getShortName()); |
76 | 83 | } |
77 | 84 | |
78 | 85 | $type = $this->r->apply($display, 'value', $type); |
79 | 86 | |
80 | - if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG) { |
|
87 | + if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG) |
|
88 | + { |
|
81 | 89 | $result[] = sprintf('<span>%s</span>', $type); |
82 | - } else { |
|
90 | + } |
|
91 | + else |
|
92 | + { |
|
83 | 93 | $hash = is_object($arg) ? spl_object_hash($arg) : md5(json_encode($arg)); |
84 | 94 | |
85 | - if (!isset($this->values[$hash])) { |
|
95 | + if (!isset($this->values[$hash])) |
|
96 | + { |
|
86 | 97 | $this->values[$hash] = $this->dumper->dump($arg, Dumper::RETURN); |
87 | 98 | } |
88 | 99 |
@@ -83,7 +83,7 @@ |
||
83 | 83 | $hash = is_object($arg) ? spl_object_hash($arg) : md5(json_encode($arg)); |
84 | 84 | |
85 | 85 | if (!isset($this->values[$hash])) { |
86 | - $this->values[$hash] = $this->dumper->dump($arg, Dumper::RETURN); |
|
86 | + $this->values[$hash] = $this->dumper->dump($arg, Dumper::return); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | $result[] = sprintf('<span onclick="_da(\'%s\')">%s</span>', $hash, $type); |
@@ -73,16 +73,19 @@ |
||
73 | 73 | */ |
74 | 74 | public function handle(Request $request): Response |
75 | 75 | { |
76 | - if (empty($this->handler)) { |
|
76 | + if (empty($this->handler)) |
|
77 | + { |
|
77 | 78 | throw new PipelineException('Unable to run pipeline, no handler given.'); |
78 | 79 | } |
79 | 80 | |
80 | 81 | $position = $this->position++; |
81 | - if (isset($this->middleware[$position])) { |
|
82 | + if (isset($this->middleware[$position])) |
|
83 | + { |
|
82 | 84 | return $this->middleware[$position]->process($request, $this); |
83 | 85 | } |
84 | 86 | |
85 | - return $this->scope->runScope([Request::class => $request], function () use ($request) { |
|
87 | + return $this->scope->runScope([Request::class => $request], function () use ($request) |
|
88 | + { |
|
86 | 89 | return $this->handler->handle($request); |
87 | 90 | }); |
88 | 91 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | public const NONE = 'None'; |
12 | 12 | |
13 | 13 | private const VALUES = [self::STRICT, self::LAX, self::NONE]; |
14 | - private const DEFAULT = self::LAX; |
|
14 | + private const default = self::LAX; |
|
15 | 15 | |
16 | 16 | /** @var string|null */ |
17 | 17 | private $sameSite; |
@@ -42,6 +42,6 @@ discard block |
||
42 | 42 | return null; |
43 | 43 | } |
44 | 44 | |
45 | - return ($sameSite === self::NONE && !$secure) ? self::DEFAULT : $sameSite; |
|
45 | + return ($sameSite === self::NONE && !$secure) ? self::default : $sameSite; |
|
46 | 46 | } |
47 | 47 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | { |
50 | 50 | $name = $name ?? $this->default; |
51 | 51 | |
52 | - if (!isset($this->transports[$name])) { |
|
52 | + if (!isset($this->transports[$name])){ |
|
53 | 53 | throw new TransportException("Undefined auth transport {$name}"); |
54 | 54 | } |
55 | 55 |
@@ -49,7 +49,8 @@ |
||
49 | 49 | { |
50 | 50 | $name = $name ?? $this->default; |
51 | 51 | |
52 | - if (!isset($this->transports[$name])) { |
|
52 | + if (!isset($this->transports[$name])) |
|
53 | + { |
|
53 | 54 | throw new TransportException("Undefined auth transport {$name}"); |
54 | 55 | } |
55 | 56 |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * Argument types. |
23 | 23 | */ |
24 | - public const CONSTANT = 'constant'; //Scalar constant and not variable. |
|
25 | - public const VARIABLE = 'variable'; //PHP variable |
|
24 | + public const CONSTANT = 'constant'; //Scalar constant and not variable. |
|
25 | + public const VARIABLE = 'variable'; //PHP variable |
|
26 | 26 | public const EXPRESSION = 'expression'; //PHP code (expression). |
27 | - public const STRING = 'string'; //Simple scalar string, can be fetched using stringValue(). |
|
27 | + public const STRING = 'string'; //Simple scalar string, can be fetched using stringValue(). |
|
28 | 28 | |
29 | 29 | /** @var string */ |
30 | 30 | private $type; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function stringValue(): string |
71 | 71 | { |
72 | - if ($this->type != self::STRING) { |
|
72 | + if ($this->type != self::STRING){ |
|
73 | 73 | throw new ReflectionException( |
74 | 74 | "Unable to represent value as string, value type is '{$this->type}'" |
75 | 75 | ); |
@@ -91,19 +91,19 @@ discard block |
||
91 | 91 | $level = 0; |
92 | 92 | |
93 | 93 | $result = []; |
94 | - foreach ($tokens as $token) { |
|
95 | - if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE) { |
|
94 | + foreach ($tokens as $token){ |
|
95 | + if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE){ |
|
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | - if (empty($definition)) { |
|
99 | + if (empty($definition)){ |
|
100 | 100 | $definition = ['type' => self::EXPRESSION, 'value' => '', 'tokens' => []]; |
101 | 101 | } |
102 | 102 | |
103 | 103 | if ( |
104 | 104 | $token[ReflectionFile::TOKEN_TYPE] == '(' |
105 | 105 | || $token[ReflectionFile::TOKEN_TYPE] == '[' |
106 | - ) { |
|
106 | + ){ |
|
107 | 107 | ++$level; |
108 | 108 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
109 | 109 | continue; |
@@ -112,18 +112,18 @@ discard block |
||
112 | 112 | if ( |
113 | 113 | $token[ReflectionFile::TOKEN_TYPE] == ')' |
114 | 114 | || $token[ReflectionFile::TOKEN_TYPE] == ']' |
115 | - ) { |
|
115 | + ){ |
|
116 | 116 | --$level; |
117 | 117 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
118 | 118 | continue; |
119 | 119 | } |
120 | 120 | |
121 | - if ($level) { |
|
121 | + if ($level){ |
|
122 | 122 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | |
126 | - if ($token[ReflectionFile::TOKEN_TYPE] == ',') { |
|
126 | + if ($token[ReflectionFile::TOKEN_TYPE] == ','){ |
|
127 | 127 | $result[] = self::createArgument($definition); |
128 | 128 | $definition = null; |
129 | 129 | continue; |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | //Last argument |
137 | - if (is_array($definition)) { |
|
137 | + if (is_array($definition)){ |
|
138 | 138 | $definition = self::createArgument($definition); |
139 | - if (!empty($definition->getType())) { |
|
139 | + if (!empty($definition->getType())){ |
|
140 | 140 | $result[] = $definition; |
141 | 141 | } |
142 | 142 | } |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | { |
156 | 156 | $result = new static(self::EXPRESSION, $definition['value']); |
157 | 157 | |
158 | - if (count($definition['tokens']) == 1) { |
|
158 | + if (count($definition['tokens']) == 1){ |
|
159 | 159 | //If argument represent by one token we can try to resolve it's type more precisely |
160 | - switch ($definition['tokens'][0][0]) { |
|
160 | + switch ($definition['tokens'][0][0]){ |
|
161 | 161 | case T_VARIABLE: |
162 | 162 | $result->type = self::VARIABLE; |
163 | 163 | break; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | TranslatorConfig $config, |
45 | 45 | CatalogueManagerInterface $catalogueManager, |
46 | 46 | IdentityTranslator $identityTranslator = null |
47 | - ) { |
|
47 | + ){ |
|
48 | 48 | $this->config = $config; |
49 | 49 | $this->identityTranslator = $identityTranslator ?? new IdentityTranslator(); |
50 | 50 | $this->catalogueManager = $catalogueManager; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function setLocale(string $locale): void |
70 | 70 | { |
71 | - if (!$this->catalogueManager->has($locale)) { |
|
71 | + if (!$this->catalogueManager->has($locale)){ |
|
72 | 72 | throw new LocaleException($locale); |
73 | 73 | } |
74 | 74 | |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | array $parameters = [], |
125 | 125 | $domain = null, |
126 | 126 | $locale = null |
127 | - ) { |
|
127 | + ){ |
|
128 | 128 | $domain = $domain ?? $this->config->getDefaultDomain(); |
129 | 129 | $locale = $locale ?? $this->locale; |
130 | 130 | |
131 | - try { |
|
131 | + try{ |
|
132 | 132 | $message = $this->get($locale, $domain, $id); |
133 | 133 | |
134 | 134 | $pluralized = $this->identityTranslator->trans( |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | null, |
138 | 138 | $locale |
139 | 139 | ); |
140 | - } catch (\InvalidArgumentException $e) { |
|
140 | + }catch (\InvalidArgumentException $e){ |
|
141 | 141 | //Wrapping into more explanatory exception |
142 | 142 | throw new PluralizationException($e->getMessage(), $e->getCode(), $e); |
143 | 143 | } |
144 | 144 | |
145 | - if (empty($parameters['n']) && is_numeric($number)) { |
|
145 | + if (empty($parameters['n']) && is_numeric($number)){ |
|
146 | 146 | $parameters['n'] = $number; |
147 | 147 | } |
148 | 148 | |
@@ -168,18 +168,18 @@ discard block |
||
168 | 168 | string $postfix = '}' |
169 | 169 | ): string { |
170 | 170 | $replaces = []; |
171 | - foreach ($values as $key => $value) { |
|
171 | + foreach ($values as $key => $value){ |
|
172 | 172 | $value = (is_array($value) || $value instanceof \Closure) ? '' : $value; |
173 | 173 | |
174 | - if (is_object($value)) { |
|
175 | - if (method_exists($value, '__toString')) { |
|
174 | + if (is_object($value)){ |
|
175 | + if (method_exists($value, '__toString')){ |
|
176 | 176 | $value = $value->__toString(); |
177 | - } else { |
|
177 | + }else{ |
|
178 | 178 | $value = ''; |
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | - $replaces[$prefix . $key . $postfix] = $value; |
|
182 | + $replaces[$prefix.$key.$postfix] = $value; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return strtr($string, $replaces); |
@@ -207,18 +207,18 @@ discard block |
||
207 | 207 | */ |
208 | 208 | protected function get(string &$locale, string $domain, string $string): string |
209 | 209 | { |
210 | - if ($this->catalogueManager->get($locale)->has($domain, $string)) { |
|
210 | + if ($this->catalogueManager->get($locale)->has($domain, $string)){ |
|
211 | 211 | return $this->catalogueManager->get($locale)->get($domain, $string); |
212 | 212 | } |
213 | 213 | |
214 | 214 | $locale = $this->config->getFallbackLocale(); |
215 | 215 | |
216 | - if ($this->catalogueManager->get($locale)->has($domain, $string)) { |
|
216 | + if ($this->catalogueManager->get($locale)->has($domain, $string)){ |
|
217 | 217 | return $this->catalogueManager->get($locale)->get($domain, $string); |
218 | 218 | } |
219 | 219 | |
220 | 220 | // we can automatically register message |
221 | - if ($this->config->isAutoRegisterMessages()) { |
|
221 | + if ($this->config->isAutoRegisterMessages()){ |
|
222 | 222 | $this->catalogueManager->get($locale)->set($domain, $string, $string); |
223 | 223 | $this->catalogueManager->save($locale); |
224 | 224 | } |
@@ -68,7 +68,8 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function setLocale(string $locale): void |
70 | 70 | { |
71 | - if (!$this->catalogueManager->has($locale)) { |
|
71 | + if (!$this->catalogueManager->has($locale)) |
|
72 | + { |
|
72 | 73 | throw new LocaleException($locale); |
73 | 74 | } |
74 | 75 | |
@@ -128,7 +129,8 @@ discard block |
||
128 | 129 | $domain = $domain ?? $this->config->getDefaultDomain(); |
129 | 130 | $locale = $locale ?? $this->locale; |
130 | 131 | |
131 | - try { |
|
132 | + try |
|
133 | + { |
|
132 | 134 | $message = $this->get($locale, $domain, $id); |
133 | 135 | |
134 | 136 | $pluralized = $this->identityTranslator->trans( |
@@ -137,12 +139,15 @@ discard block |
||
137 | 139 | null, |
138 | 140 | $locale |
139 | 141 | ); |
140 | - } catch (\InvalidArgumentException $e) { |
|
142 | + } |
|
143 | + catch (\InvalidArgumentException $e) |
|
144 | + { |
|
141 | 145 | //Wrapping into more explanatory exception |
142 | 146 | throw new PluralizationException($e->getMessage(), $e->getCode(), $e); |
143 | 147 | } |
144 | 148 | |
145 | - if (empty($parameters['n']) && is_numeric($number)) { |
|
149 | + if (empty($parameters['n']) && is_numeric($number)) |
|
150 | + { |
|
146 | 151 | $parameters['n'] = $number; |
147 | 152 | } |
148 | 153 | |
@@ -168,13 +173,18 @@ discard block |
||
168 | 173 | string $postfix = '}' |
169 | 174 | ): string { |
170 | 175 | $replaces = []; |
171 | - foreach ($values as $key => $value) { |
|
176 | + foreach ($values as $key => $value) |
|
177 | + { |
|
172 | 178 | $value = (is_array($value) || $value instanceof \Closure) ? '' : $value; |
173 | 179 | |
174 | - if (is_object($value)) { |
|
175 | - if (method_exists($value, '__toString')) { |
|
180 | + if (is_object($value)) |
|
181 | + { |
|
182 | + if (method_exists($value, '__toString')) |
|
183 | + { |
|
176 | 184 | $value = $value->__toString(); |
177 | - } else { |
|
185 | + } |
|
186 | + else |
|
187 | + { |
|
178 | 188 | $value = ''; |
179 | 189 | } |
180 | 190 | } |
@@ -207,18 +217,21 @@ discard block |
||
207 | 217 | */ |
208 | 218 | protected function get(string &$locale, string $domain, string $string): string |
209 | 219 | { |
210 | - if ($this->catalogueManager->get($locale)->has($domain, $string)) { |
|
220 | + if ($this->catalogueManager->get($locale)->has($domain, $string)) |
|
221 | + { |
|
211 | 222 | return $this->catalogueManager->get($locale)->get($domain, $string); |
212 | 223 | } |
213 | 224 | |
214 | 225 | $locale = $this->config->getFallbackLocale(); |
215 | 226 | |
216 | - if ($this->catalogueManager->get($locale)->has($domain, $string)) { |
|
227 | + if ($this->catalogueManager->get($locale)->has($domain, $string)) |
|
228 | + { |
|
217 | 229 | return $this->catalogueManager->get($locale)->get($domain, $string); |
218 | 230 | } |
219 | 231 | |
220 | 232 | // we can automatically register message |
221 | - if ($this->config->isAutoRegisterMessages()) { |
|
233 | + if ($this->config->isAutoRegisterMessages()) |
|
234 | + { |
|
222 | 235 | $this->catalogueManager->get($locale)->set($domain, $string, $string); |
223 | 236 | $this->catalogueManager->save($locale); |
224 | 237 | } |