Passed
Pull Request — master (#121)
by Arnaud
03:50
created

TranslationUtils   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 40
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getActionTranslationKey() 0 9 1
A getTranslationKey() 0 9 1
1
<?php
2
3
namespace LAG\AdminBundle\Utils;
4
5
class TranslationUtils
6
{
7
    /**
8
     * Return the translation pattern with keys "{admin}" and "{key}" replaced by their values.
9
     *
10
     * @param string $translationPattern
11
     * @param string $adminName
12
     * @param string $key
13
     *
14
     * @return string
15
     */
16
    public static function getTranslationKey(
17
        string $translationPattern,
18
        string $adminName,
19
        string $key
20
    ): string {
21
        $translationPattern = str_replace('{key}', $key, $translationPattern);
22
        $translationPattern = str_replace('{admin}', $adminName, $translationPattern);
23
24
        return $translationPattern;
25
    }
26
27
    /**
28
     * Return the translation pattern with keys "{admin}" and "{key}" replaced by their values.
29
     *
30
     * @param string $translationPattern
31
     * @param string $adminName
32
     * @param string $actionName
33
     *
34
     * @return string
35
     */
36
    public static function getActionTranslationKey(
37
        string $translationPattern,
38
        string $adminName,
39
        string $actionName
40
    ): string {
41
        $translationPattern = str_replace('{key}', $actionName, $translationPattern);
42
        $translationPattern = str_replace('{admin}', $adminName, $translationPattern);
43
44
        return $translationPattern;
45
    }
46
}
47