Passed
Branch ops-updates (277b44)
by Björn
05:09
created

Languagemenu   D

Complexity

Total Complexity 59

Size/Duplication

Total Lines 532
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 149
c 0
b 0
f 0
dl 0
loc 532
rs 4.08
wmc 59

35 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubLiClassLevel0() 0 2 1
A getLabelMethod() 0 3 1
A setSubLiClassLevel0() 0 3 1
A setOmitCurrent() 0 4 1
A setUlClass() 0 4 1
A checkLocaleMethod() 0 18 2
A getUlClass() 0 3 1
A setLabelMethod() 0 6 1
A getSubLiClass() 0 2 1
A setTitleMethod() 0 6 1
A setDefaultLiClass() 0 3 1
A getDefaultLiClass() 0 2 1
A setDetector() 0 4 1
A setIconPrefixClass() 0 3 1
A getLabelInCurrentLocale() 0 3 1
A getTitleMethod() 0 3 1
A __invoke() 0 4 1
A getHtmlifyPartial() 0 3 1
A getDetector() 0 10 3
C buildComponent() 0 66 15
A getIconPrefixClass() 0 2 1
A getSubUlClassLevel1() 0 2 1
A setHrefSubToggleOverride() 0 3 1
A render() 0 14 3
A getHrefSubToggleOverride() 0 2 1
A setSubLiClass() 0 3 1
A setHtmlifyPartial() 0 7 4
A setTitleInCurrentLocale() 0 4 1
A setSubUlClass() 0 3 1
A setSubUlClassLevel1() 0 3 1
A omitCurrent() 0 3 1
A getTitleInCurrentLocale() 0 3 1
A getLocaleProperty() 0 11 3
A getSubUlClass() 0 2 1
A setLabelInCurrentLocale() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Languagemenu often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Languagemenu, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * BB's Zend Framework 2 Components
4
 * 
5
 * UI Components
6
 *
7
 * @package     [MyApplication]
8
 * @subpackage  BB's Zend Framework 2 Components
9
 * @subpackage  UI Components
10
 * @author      Björn Bartels <[email protected]>
11
 * @link        https://gitlab.bjoernbartels.earth/groups/zf2
12
 * @license     http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
13
 * @copyright   copyright (c) 2016 Björn Bartels <[email protected]>
14
 */
15
16
namespace UIComponents\View\Helper\Components;
17
18
use Zend\View\HelperPluginManager;
19
use Locale;
20
use \UIComponents\View\Helper\Traits\ComponentAttributesTrait;
0 ignored issues
show
Bug introduced by
The type \UIComponents\View\Helpe...omponentAttributesTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
22
class Languagemenu extends \UIComponents\View\Helper\AbstractHelper
23
24
{
25
    use ComponentAttributesTrait;
26
    
27
    /**
28
     * @var Detector $detector
0 ignored issues
show
Bug introduced by
The type UIComponents\View\Helper\Components\Detector was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
29
     */
30
    protected $detector;
31
32
    /**
33
     * Set the class to be used on the list container
34
     *
35
     * @var string || null
0 ignored issues
show
Documentation Bug introduced by
The doc comment string || null at position 2 could not be parsed: Unknown type name '|' at position 2 in string || null.
Loading history...
36
     */
37
    protected $class;
38
39
    /**
40
     * Method used to construct a title for each item
41
     *
42
     * @var string || null
0 ignored issues
show
Documentation Bug introduced by
The doc comment string || null at position 2 could not be parsed: Unknown type name '|' at position 2 in string || null.
Loading history...
43
     */
44
    protected $titleMethod = 'displayLanguage';
45
46
    /**
47
     * Flag to specify specifies whether the title should be in the current locale
48
     *
49
     * @var boolean default false
50
     */
51
    protected $titleInCurrentLocale = false;
52
53
    /**
54
     * Method used to construct a label for each item
55
     *
56
     * @var string || null
0 ignored issues
show
Documentation Bug introduced by
The doc comment string || null at position 2 could not be parsed: Unknown type name '|' at position 2 in string || null.
Loading history...
57
     */
58
    protected $labelMethod = 'displayLanguage';
59
60
    /**
61
     * Flag to specify specifies whether the label should be in the current locale
62
     *
63
     * @var boolean default true
64
     */
65
    protected $labelInCurrentLocale = true;
66
67
    /**
68
     * Flag to specify the current locale should be omitted from the menu
69
     *
70
     * @var boolean default false
71
     */
72
    protected $omitCurrent = false;
73
74
    /**
75
     * default CSS class to use for li elements
76
     *
77
     * @var string
78
     */
79
    protected $defaultLiClass = '';
80
81
    /**
82
     * CSS class to use for the ul sub-menu element
83
     *
84
     * @var string
85
     */
86
    protected $subUlClass = 'dropdown-menu';
87
88
    /**
89
     * CSS class to use for the 1. level (NOT root level!) ul sub-menu element
90
     *
91
     * @var string
92
     */
93
    protected $subUlClassLevel1 = 'dropdown-menu';
94
95
    /**
96
     * CSS class to use for the active li sub-menu element
97
     *
98
     * @var string
99
     */
100
    protected $subLiClass = 'dropdown-submenu';
101
102
    /**
103
     * CSS class to use for the active li sub-menu element
104
     *
105
     * @var string
106
     */
107
    protected $subLiClassLevel0 = 'dropdown';
108
109
    /**
110
     * CSS class prefix to use for the menu element's icon class
111
     *
112
     * @var string
113
     */
114
    protected $iconPrefixClass = 'icon-';
115
116
    /**
117
     * HREF string to use for the sub-menu toggle element's HREF attribute, 
118
     * to override current page's href/'htmlify' setting
119
     *
120
     * @var string
121
     */
122
    protected $hrefSubToggleOverride = null;
123
124
    /**
125
     * Partial view script to use for rendering menu link/item
126
     *
127
     * @var string|array
128
     */
129
    protected $htmlifyPartial = null;
130
131
    /**
132
     * @param Detector $detector
133
     */
134
    public function setDetector($detector)
135
    {
136
        $this->detector = $detector;
137
        return $this;
138
    }
139
140
    /**
141
     * @return Detector $detector
142
     */
143
    public function getDetector()
144
    {
145
        if (!$this->detector) {
146
            $serviceLocator = $this->getServiceLocator();
147
            if ($serviceLocator instanceof HelperPluginManager) {
148
                $serviceLocator = $serviceLocator->getServiceLocator();
149
            }
150
            $this->detector = $serviceLocator->get('SlmLocale\Locale\Detector');
0 ignored issues
show
Documentation Bug introduced by
It seems like $serviceLocator->get('SlmLocale\Locale\Detector') can also be of type array. However, the property $detector is declared as type UIComponents\View\Helper\Components\Detector. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
151
        }
152
        return $this->detector;
153
    }
154
155
    /**
156
     * @param string $class
157
     */
158
    public function setUlClass($class)
159
    {
160
        $this->class = $class;
161
        return $this;
162
    }
163
164
    /**
165
     * @return string
166
     */
167
    public function getUlClass()
168
    {
169
        return $this->class;
170
    }
171
172
    /**
173
     * @param string $itemTitleMethod
174
     */
175
    public function setTitleMethod($titleMethod)
176
    {
177
        $this->checkLocaleMethod($titleMethod);
178
179
        $this->titleMethod = $titleMethod;
180
        return $this;
181
    }
182
183
    /**
184
     * @return string
185
     */
186
    public function getTitleMethod()
187
    {
188
        return $this->titleMethod;
189
    }
190
191
    /**
192
     * @param boolean $flag
193
     */
194
    public function setTitleInCurrentLocale($flag)
195
    {
196
        $this->titleInCurrentLocale = (bool) $flag;
197
        return $this;
198
    }
199
200
    /**
201
     * @return boolean
202
     */
203
    public function getTitleInCurrentLocale()
204
    {
205
        return $this->titleInCurrentLocale;
206
    }
207
208
    /**
209
     * @param string $labelMethod
210
     */
211
    public function setLabelMethod($labelMethod)
212
    {
213
        $this->checkLocaleMethod($labelMethod);
214
215
        $this->labelMethod = $labelMethod;
216
        return $this;
217
    }
218
219
    /**
220
     * @return string
221
     */
222
    public function getLabelMethod()
223
    {
224
        return $this->labelMethod;
225
    }
226
227
    /**
228
     * @param boolean $flag
229
     */
230
    public function setLabelInCurrentLocale($flag)
231
    {
232
        $this->labelInCurrentLocale = (bool) $flag;
233
        return $this;
234
    }
235
236
    /**
237
     * @return boolean
238
     */
239
    public function getLabelInCurrentLocale()
240
    {
241
        return $this->labelInCurrentLocale;
242
    }
243
244
    /**
245
     * @param boolean $omitCurrent
246
     */
247
    public function setOmitCurrent($omitCurrent)
248
    {
249
        $this->omitCurrent = (bool) $omitCurrent;
250
        return $this;
251
    }
252
253
    /**
254
     * @return boolean
255
     */
256
    public function omitCurrent()
257
    {
258
        return $this->omitCurrent;
259
    }
260
    
261
    /**
262
     * @return the $defaultLiClass
0 ignored issues
show
Bug introduced by
The type UIComponents\View\Helper\Components\the was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
263
     */
264
    public function getDefaultLiClass() {
265
        return $this->defaultLiClass;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->defaultLiClass returns the type string which is incompatible with the documented return type UIComponents\View\Helper\Components\the.
Loading history...
266
    }
267
268
    /**
269
     * @param string $defaultLiClass
270
     */
271
    public function setDefaultLiClass($defaultLiClass) {
272
        $this->defaultLiClass = $defaultLiClass;
273
        return $this;
274
    }
275
276
    /**
277
     * @return the $subUlClass
278
     */
279
    public function getSubUlClass() {
280
        return $this->subUlClass;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->subUlClass returns the type string which is incompatible with the documented return type UIComponents\View\Helper\Components\the.
Loading history...
281
    }
282
283
    /**
284
     * @param string $subUlClass
285
     */
286
    public function setSubUlClass($subUlClass) {
287
        $this->subUlClass = $subUlClass;
288
        return $this;
289
    }
290
291
    /**
292
     * @return the $subUlClassLevel1
293
     */
294
    public function getSubUlClassLevel1() {
295
        return $this->subUlClassLevel1;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->subUlClassLevel1 returns the type string which is incompatible with the documented return type UIComponents\View\Helper\Components\the.
Loading history...
296
    }
297
298
    /**
299
     * @param string $subUlClassLevel1
300
     */
301
    public function setSubUlClassLevel1($subUlClassLevel1) {
302
        $this->subUlClassLevel1 = $subUlClassLevel1;
303
        return $this;
304
    }
305
306
    /**
307
     * @return the $subLiClass
308
     */
309
    public function getSubLiClass() {
310
        return $this->subLiClass;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->subLiClass returns the type string which is incompatible with the documented return type UIComponents\View\Helper\Components\the.
Loading history...
311
    }
312
313
    /**
314
     * @param string $subLiClass
315
     */
316
    public function setSubLiClass($subLiClass) {
317
        $this->subLiClass = $subLiClass;
318
        return $this;
319
    }
320
321
    /**
322
     * @return the $subLiClassLevel0
323
     */
324
    public function getSubLiClassLevel0() {
325
        return $this->subLiClassLevel0;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->subLiClassLevel0 returns the type string which is incompatible with the documented return type UIComponents\View\Helper\Components\the.
Loading history...
326
    }
327
    
328
    /**
329
     * @param string $subLiClassLevel0
330
     */
331
    public function setSubLiClassLevel0($subLiClassLevel0) {
332
        $this->subLiClassLevel0 = $subLiClassLevel0;
333
        return $this;
334
    }
335
    
336
    /**
337
     * @return the $iconPrefixClass
338
     */
339
    public function getIconPrefixClass() {
340
        return $this->iconPrefixClass;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->iconPrefixClass returns the type string which is incompatible with the documented return type UIComponents\View\Helper\Components\the.
Loading history...
341
    }
342
343
    /**
344
     * @param string $iconPrefixClass
345
     */
346
    public function setIconPrefixClass($iconPrefixClass) {
347
        $this->iconPrefixClass = $iconPrefixClass;
348
        return $this;
349
    }
350
    
351
    /**
352
     * @return the $hrefSubToggleOverride
353
     */
354
    public function getHrefSubToggleOverride() {
355
        return $this->hrefSubToggleOverride;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->hrefSubToggleOverride returns the type string which is incompatible with the documented return type UIComponents\View\Helper\Components\the.
Loading history...
356
    }
357
358
    /**
359
     * @param string $hrefSubToggleOverride
360
     */
361
    public function setHrefSubToggleOverride($hrefSubToggleOverride) {
362
        $this->hrefSubToggleOverride = $hrefSubToggleOverride;
363
        return $this;
364
    }
365
366
    /**
367
     * Sets which partial view script to use for rendering menu
368
     *
369
     * @param    string|array $partial partial view script or null. If an array is
370
     *                                given, it is expected to contain two
371
     *                                values; the partial view script to use,
372
     *                                and the module where the script can be
373
     *                                found.
374
     * @return self
375
     */
376
    public function setHtmlifyPartial($partial)
377
    {
378
        if (null === $partial || is_string($partial) || is_array($partial)) {
0 ignored issues
show
introduced by
The condition is_array($partial) is always true.
Loading history...
379
            $this->htmlifyPartial = $partial;
380
        }
381
    
382
        return $this;
383
    }
384
    
385
    /**
386
     * Returns partial view script to use for rendering menu
387
     *
388
     * @return string|array|null
389
     */
390
    public function getHtmlifyPartial()
391
    {
392
        return $this->htmlifyPartial;
393
    }
394
    
395
    /**
396
     * View helper entry point:
397
     * Retrieves helper and optionally sets component options to operate on
398
     *
399
     * @param  array|StdClass $options [optional] component options to operate on
0 ignored issues
show
Bug introduced by
The type UIComponents\View\Helper\Components\StdClass was not found. Did you mean StdClass? If so, make sure to prefix the type with \.
Loading history...
400
     * @return self
401
     */
402
    public function __invoke($options = array())
403
    {
404
        parent::__invoke($options);
405
        return $this;
406
    }
407
    
408
    /**
409
     * render component
410
     *
411
     * @param boolean $output
412
     *
413
     * @return string
414
     */
415
    public function render($output = false)
416
    {
417
        try {
418
             
419
            if ($output) {
420
                echo $this->buildComponent();
421
            }
422
            return $this->buildComponent();
423
                
424
        } catch (\Exception $e) {
425
             
426
            $msg = get_class($e) . ': ' . $e->getMessage() . "\n" . $e->getTraceAsString();
427
            trigger_error($msg, E_USER_ERROR);
428
            return '';
429
    
430
        }
431
    }
432
    
433
    /**
434
     * build markup
435
     *
436
     * @return string
437
     */
438
    public function buildComponent()
439
    {    
440
        if (!($detector = $this->getDetector())) {
441
            throw new \RuntimeException('To assemble an url, a detector is required');
442
        }
443
444
        $class = $this->getUlClass();
445
        $liclass = $this->getSubLiClassLevel0();
446
        $subulclass = $this->getSubUlClassLevel1();
447
        $iconprefixclass = $this->getIconPrefixClass();
448
449
        $list     = '';
450
        $current  = Locale::getDefault();
451
        foreach($detector->getSupported() as $locale) {
452
            if ($this->omitCurrent() && $current === $locale) {
453
                continue;
454
            }
455
456
            $titleLocale = $this->getTitleInCurrentLocale() ? $locale : $current;
457
            $labelLocale = $this->getLabelInCurrentLocale() ? $locale : $current;
458
459
            $url   = $this->getView()->localeUrl($locale);
0 ignored issues
show
Bug introduced by
The method localeUrl() does not exist on Zend\View\Renderer\RendererInterface. It seems like you code against a sub-type of Zend\View\Renderer\RendererInterface such as Zend\View\Renderer\PhpRenderer. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

459
            $url   = $this->getView()->/** @scrutinizer ignore-call */ localeUrl($locale);
Loading history...
460
            $title = $this->getLocaleProperty($this->getTitleMethod(), $locale, $titleLocale);
0 ignored issues
show
Bug introduced by
It seems like $titleLocale can also be of type string; however, parameter $in_locale of UIComponents\View\Helper...nu::getLocaleProperty() does only seem to accept boolean, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

460
            $title = $this->getLocaleProperty($this->getTitleMethod(), $locale, /** @scrutinizer ignore-type */ $titleLocale);
Loading history...
Unused Code introduced by
The assignment to $title is dead and can be removed.
Loading history...
461
            $label = $this->getLocaleProperty($this->getLabelMethod(), $locale, $labelLocale);
462
            $primary = $this->getLocaleProperty('primaryLanguage', $locale, true);
463
            $displayName = $this->getLocaleProperty('displayName', $locale, $labelLocale);
464
465
            $item = sprintf(
466
                '<li><a href="%s" title="%s"%s %s>%s</a></li>' . "\n",
467
                $url,
468
                $displayName,
469
                ($current === $locale) ? ' class="active"' : '',
470
                'data-test="cta-lang-'.$this->slugify($label).'"',
471
                (($iconprefixclass) ? '<span class="' . $iconprefixclass . $primary . '"></span> ' : '') . $label
472
            );
473
474
            $list .= $item;
475
        }
476
        $attributes = $this->getAttributes();
477
        $html  = 
478
            '<ul'.(($class) ? sprintf(' class="%s"', $class) : '').' '.($this->htmlAttribs($attributes)).'>'.
479
                '<li'.(($liclass) ? sprintf(' class="%s"', $liclass) : '').'>'.
0 ignored issues
show
introduced by
$liclass is of type UIComponents\View\Helper\Components\the, thus it always evaluated to true.
Loading history...
480
                    '<a href="" '.
481
                        'class="'.(($liclass) ? $liclass.'-toggle' : '').'" '.
0 ignored issues
show
introduced by
$liclass is of type UIComponents\View\Helper\Components\the, thus it always evaluated to true.
Loading history...
482
                        'data-toggle="'.(($liclass) ? $liclass : '').'" '.
0 ignored issues
show
introduced by
$liclass is of type UIComponents\View\Helper\Components\the, thus it always evaluated to true.
Loading history...
483
                        'role="button" aria-haspopup="true" '.
484
                        'aria-expanded="false" '.
485
                        'title="'.Locale::getDisplayName(null).'"'.
486
                        'data-test="cta-lang-selector cta-lang-selected-'.$this->slugify(Locale::getDisplayLanguage(null)).'"'.
487
                    '>'.
488
                        '<span class="'.(($iconprefixclass) ? $iconprefixclass : '').Locale::getPrimaryLanguage(null).'"></span> '.
0 ignored issues
show
introduced by
$iconprefixclass is of type UIComponents\View\Helper\Components\the, thus it always evaluated to true.
Loading history...
489
                        ''.Locale::getDisplayLanguage(null). // ' - '.Locale::getDefault().' - '.Locale::getPrimaryLanguage(null).''.
490
                        '<span class="caret"></span>'.
491
                    '</a>'.
492
                       sprintf(
493
                        '<ul%s>%s</ul>',
494
                        ($subulclass) ? sprintf(' class="%s"', $subulclass) : '',
0 ignored issues
show
introduced by
$subulclass is of type UIComponents\View\Helper\Components\the, thus it always evaluated to true.
Loading history...
495
                        $list
496
                       ).
497
                   '</li>'.
498
            '</ul>'
499
        ;
500
501
        return $html;
502
        
503
        return '<h2>'.__CLASS__.'</h2>';
0 ignored issues
show
Unused Code introduced by
return '<h2>' . __CLASS__ . '</h2>' is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
504
    }
505
    
506
    /**
507
     * Check whether method part of the Locale class is
508
     *
509
     * @param  string $method Method to check
510
     * @throws RuntimeException If method is not part of locale
511
     * @return true
512
     */
513
    protected function checkLocaleMethod($method)
514
    {
515
        $options = array(
516
                'displayLanguage',
517
                'displayName',
518
                'displayRegion',
519
                'displayScript',
520
                'displayVariant',
521
                'primaryLanguage',
522
                'region',
523
                'script'
524
        );
525
    
526
        if (!in_array($method, $options)) {
527
            throw new RuntimeException(sprintf(
0 ignored issues
show
Bug introduced by
The type UIComponents\View\Helper...onents\RuntimeException was not found. Did you mean RuntimeException? If so, make sure to prefix the type with \.
Loading history...
528
                    'Unknown method "%s" for Locale, expecting one of these: %s.',
529
                    $method,
530
                    implode(', ', $options)
531
            ));
532
        }
533
    }
534
    
535
    /**
536
     * Retrieves a value by property from Locale
537
     *
538
     * @param $property
539
     * @param $locale
540
     * @param bool $in_locale
541
     * @return mixed
542
     */
543
    protected function getLocaleProperty($property, $locale, $in_locale = false)
544
    {
545
        $callback = sprintf('\Locale::get%s', ucfirst($property));
546
    
547
        $args = array($locale);
548
    
549
        if ($in_locale && !in_array($property, array('primaryLanguage', 'region', 'script'))) {
550
            $args[] = $in_locale;
551
        }
552
    
553
        return call_user_func_array($callback, $args);
554
    }
555
    
556
}