@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $translations = $this->getTranslations(); |
32 | 32 | $entries = $this->filter( $translations, $this->entries() )->results(); |
33 | - array_walk( $translations, function( &$entry ) use( $entries ) { |
|
33 | + array_walk( $translations, function( &$entry ) use($entries) { |
|
34 | 34 | $entry['desc'] = array_key_exists( $entry['id'], $entries ) |
35 | 35 | ? $this->getEntryString( $entries[$entry['id']], 'msgctxt' ) |
36 | 36 | : ''; |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function entries() |
45 | 45 | { |
46 | - if( !isset( $this->entries )) { |
|
46 | + if( !isset($this->entries) ) { |
|
47 | 47 | try { |
48 | 48 | $entries = $this->normalize( |
49 | - Parser::parseFile( glsr()->path( 'languages/site-reviews.pot' ))->getEntries() |
|
49 | + Parser::parseFile( glsr()->path( 'languages/site-reviews.pot' ) )->getEntries() |
|
50 | 50 | ); |
51 | 51 | } |
52 | 52 | catch( Exception $e ) { |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function filter( $filterWith = null, $entries = null, $intersect = true ) |
79 | 79 | { |
80 | - if( !is_array( $entries )) { |
|
80 | + if( !is_array( $entries ) ) { |
|
81 | 81 | $entries = $this->results; |
82 | 82 | } |
83 | - if( !is_array( $filterWith )) { |
|
83 | + if( !is_array( $filterWith ) ) { |
|
84 | 84 | $filterWith = $this->getTranslations(); |
85 | 85 | } |
86 | - $keys = array_flip( array_column( $filterWith, 'id' )); |
|
86 | + $keys = array_flip( array_column( $filterWith, 'id' ) ); |
|
87 | 87 | $this->results = $intersect |
88 | 88 | ? array_intersect_key( $entries, $keys ) |
89 | 89 | : array_diff_key( $entries, $keys ); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | { |
101 | 101 | return $this->translate( $translation, $domain, [ |
102 | 102 | 'single' => $text, |
103 | - ]); |
|
103 | + ] ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | return $this->translate( $translation, $domain, [ |
116 | 116 | 'context' => $context, |
117 | 117 | 'single' => $text, |
118 | - ]); |
|
118 | + ] ); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | 'number' => $number, |
133 | 133 | 'plural' => $plural, |
134 | 134 | 'single' => $single, |
135 | - ]); |
|
135 | + ] ); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | 'number' => $number, |
152 | 152 | 'plural' => $plural, |
153 | 153 | 'single' => $single, |
154 | - ]); |
|
154 | + ] ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public function render( $template, array $entry ) |
162 | 162 | { |
163 | 163 | $data = array_combine( |
164 | - array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry )), |
|
164 | + array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ), |
|
165 | 165 | $entry |
166 | 166 | ); |
167 | 167 | ob_start(); |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | 'p1' => $this->getEntryString( $entry, 'msgid_plural' ), |
199 | 199 | 's1' => $this->getEntryString( $entry, 'msgid' ), |
200 | 200 | ]; |
201 | - $text = !empty( $data['p1'] ) |
|
201 | + $text = !empty($data['p1']) |
|
202 | 202 | ? sprintf( '%s | %s', $data['s1'], $data['p1'] ) |
203 | 203 | : $data['s1']; |
204 | 204 | $rendered .= $this->render( 'result', [ |
205 | 205 | 'entry' => wp_json_encode( $data ), |
206 | 206 | 'text' => wp_strip_all_tags( $text ), |
207 | - ]); |
|
207 | + ] ); |
|
208 | 208 | } |
209 | 209 | if( $resetAfterRender ) { |
210 | 210 | $this->reset(); |
@@ -237,12 +237,12 @@ discard block |
||
237 | 237 | public function search( $needle = '' ) |
238 | 238 | { |
239 | 239 | $this->reset(); |
240 | - $needle = trim( strtolower( $needle )); |
|
240 | + $needle = trim( strtolower( $needle ) ); |
|
241 | 241 | foreach( $this->entries() as $key => $entry ) { |
242 | - $single = strtolower( $this->getEntryString( $entry, 'msgid' )); |
|
243 | - $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' )); |
|
242 | + $single = strtolower( $this->getEntryString( $entry, 'msgid' ) ); |
|
243 | + $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) ); |
|
244 | 244 | if( strlen( $needle ) < static::SEARCH_THRESHOLD ) { |
245 | - if( in_array( $needle, [$single, $plural] )) { |
|
245 | + if( in_array( $needle, [$single, $plural] ) ) { |
|
246 | 246 | $this->results[$key] = $entry; |
247 | 247 | } |
248 | 248 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | $args = $this->normalizeTranslationArgs( $args ); |
267 | 267 | $strings = $this->getTranslationStrings( $args['single'], $args['plural'] ); |
268 | - if( empty( $strings )) { |
|
268 | + if( empty($strings) ) { |
|
269 | 269 | return $original; |
270 | 270 | } |
271 | 271 | $string = current( $strings ); |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | */ |
281 | 281 | protected function getEntryString( array $entry, $key ) |
282 | 282 | { |
283 | - return isset( $entry[$key] ) |
|
284 | - ? implode( '', (array) $entry[$key] ) |
|
283 | + return isset($entry[$key]) |
|
284 | + ? implode( '', (array)$entry[$key] ) |
|
285 | 285 | : ''; |
286 | 286 | } |
287 | 287 | |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | protected function getTranslations() |
292 | 292 | { |
293 | 293 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
294 | - return isset( $settings['translations'] ) |
|
295 | - ? $this->normalizeSettings( (array) $settings['translations'] ) |
|
294 | + return isset($settings['translations']) |
|
295 | + ? $this->normalizeSettings( (array)$settings['translations'] ) |
|
296 | 296 | : []; |
297 | 297 | } |
298 | 298 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | */ |
304 | 304 | protected function getTranslationStrings( $singleText, $pluralText ) |
305 | 305 | { |
306 | - return array_filter( $this->getTranslations(), function( $string ) use( $args ) { |
|
306 | + return array_filter( $this->getTranslations(), function( $string ) use($args) { |
|
307 | 307 | return $string['s1'] == html_entity_decode( $singleText, ENT_COMPAT, 'UTF-8' ) |
308 | 308 | && $string['p1'] == html_entity_decode( $pluralText, ENT_COMPAT, 'UTF-8' ); |
309 | 309 | }); |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $keys = [ |
318 | 318 | 'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]', |
319 | 319 | ]; |
320 | - array_walk( $entries, function( &$entry ) use( $keys ) { |
|
320 | + array_walk( $entries, function( &$entry ) use($keys) { |
|
321 | 321 | foreach( $keys as $key ) { |
322 | 322 | $entry = $this->normalizeEntryString( $entry, $key ); |
323 | 323 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | protected function normalizeEntryString( array $entry, $key ) |
333 | 333 | { |
334 | - if( isset( $entry[$key] )) { |
|
334 | + if( isset($entry[$key]) ) { |
|
335 | 335 | $entry[$key] = $this->getEntryString( $entry, $key ); |
336 | 336 | } |
337 | 337 | return $entry; |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | $defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' ); |
346 | 346 | $strings = array_filter( $strings, 'is_array' ); |
347 | 347 | foreach( $strings as &$string ) { |
348 | - $string['type'] = isset( $string['p1'] ) ? 'plural' : 'single'; |
|
348 | + $string['type'] = isset($string['p1']) ? 'plural' : 'single'; |
|
349 | 349 | $string = wp_parse_args( $string, $defaultString ); |
350 | 350 | } |
351 | 351 | return array_filter( $strings, function( $string ) { |
352 | - return !empty( $string['id'] ); |
|
352 | + return !empty($string['id']); |
|
353 | 353 | }); |
354 | 354 | } |
355 | 355 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | */ |
374 | 374 | protected function translatePlural( $domain, array $string, array $args ) |
375 | 375 | { |
376 | - if( !empty( $string['p2'] )) { |
|
376 | + if( !empty($string['p2']) ) { |
|
377 | 377 | $args['plural'] = $string['p2']; |
378 | 378 | } |
379 | 379 | return get_translations_for_domain( $domain )->translate_plural( |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | */ |
391 | 391 | protected function translateSingle( $domain, array $string, array $args ) |
392 | 392 | { |
393 | - if( !empty( $string['s2'] )) { |
|
393 | + if( !empty($string['s2']) ) { |
|
394 | 394 | $args['single'] = $string['s2']; |
395 | 395 | } |
396 | 396 | return get_translations_for_domain( $domain )->translate( |