Completed
Push — development ( 13a157...98ea90 )
by Thomas
24s
created

function.translation.php ➔ smarty_function_translation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$params" missing
Loading history...
3
 * Smarty {translation key="snippet.key"} function plugin *
4
 *
5
 * @param $params
0 ignored issues
show
Coding Style introduced by
Missing parameter name
Loading history...
introduced by
Invalid class name "$params"
Loading history...
6
 * @param $smarty
0 ignored issues
show
Coding Style introduced by
Missing parameter name
Loading history...
introduced by
Invalid class name "$smarty"
Loading history...
7
 * @return string
8
 */
9
function smarty_function_translation($params)
0 ignored issues
show
introduced by
Doc Block params do not match method signature
Loading history...
Coding Style introduced by
Type hint "params" missing for
Loading history...
10
{
11
    global $opt;
12
13
    if (!isset($params['key'])) {
14
        return '';
15
    }
16
17
    $translation = AppKernel::Container()->get(OcLegacy\Translation\TranslationService::class);
18
    $translation->setLocale(strtolower($opt['template']['locale']));
19
20
    return $translation->trans($params['key']);
21
}
22