Completed
Pull Request — master (#5)
by Benjamin
04:57
created

CoreTranslation   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 163
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 163
rs 10
wmc 19

18 Methods

Rating   Name   Duplication   Size   Complexity  
A getFieldKey() 0 3 1
A getSkillType() 0 3 1
A getMercenaryTitle() 0 3 1
A getInducementTitle() 0 3 1
A getInjuryKey() 0 3 1
A getRosterKey() 0 3 1
A getPlayerKeyType() 0 3 1
A getPlayerTranslationKey() 0 7 2
A getInducementName() 0 3 1
A getSkillNameKey() 0 3 1
A getStarPlayerName() 0 3 1
A getStarPlayerTitle() 0 3 1
A getRosterDescription() 0 3 1
A getRosterNameFor() 0 3 1
A getSkillDescription() 0 3 1
A getInjuryEffect() 0 3 1
A getRuleTitle() 0 3 1
A getWeatherKey() 0 3 1
1
<?php
2
3
namespace Obblm\Core\Helper;
4
5
use Obblm\Core\Entity\Player;
6
use Obblm\Core\Entity\Team;
7
8
class CoreTranslation
9
{
10
    const TRANSLATION_GLUE = '.';
11
12
    /***************
13
     * RULE METHODS
14
     **************/
15
16
    /**
17
     * @param $ruleKey
18
     * @return string
19
     */
20
    public static function getRuleTitle($ruleKey):string
21
    {
22
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'title']);
23
    }
24
25
    /**
26
     * @param $ruleKey
27
     * @param $roster
28
     * @return string
29
     */
30
    public static function getRosterKey($ruleKey, $roster):string
31
    {
32
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'rosters', $roster, 'title']);
33
    }
34
35
    /**
36
     * @param $ruleKey
37
     * @param $roster
38
     * @return string
39
     */
40
    public static function getRosterDescription($ruleKey, $roster):string
41
    {
42
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'rosters', $roster, 'description']);
43
    }
44
45
    /**
46
     * @param $ruleKey
47
     * @param $roster
48
     * @return string
49
     */
50
    public static function getSkillNameKey($ruleKey, $skill):string
51
    {
52
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'skills', $skill, 'title']);
53
    }
54
55
    /**
56
     * @param $ruleKey
57
     * @param $roster
58
     * @return string
59
     */
60
    public static function getSkillType($ruleKey, $type):string
61
    {
62
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'skill_types', $type]);
63
    }
64
65
    /**
66
     * @param $ruleKey
67
     * @param $roster
68
     * @return string
69
     */
70
    public static function getSkillDescription($ruleKey, $skill):string
71
    {
72
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'skills', $skill, 'description']);
73
    }
74
75
    /**
76
     * @param $ruleKey
77
     * @param $field
78
     * @return string
79
     */
80
    public static function getFieldKey($ruleKey, $field):string
81
    {
82
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'fields', $field, 'title']);
83
    }
84
85
    /**
86
     * @param $ruleKey
87
     * @param $field
88
     * @return string
89
     */
90
    public static function getWeatherKey($ruleKey, $field, $weather):string
91
    {
92
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'fields', $field, 'weather', $weather]);
93
    }
94
95
    /**
96
     * @param $ruleKey
97
     * @param $field
98
     * @return string
99
     */
100
    public static function getInjuryKey($ruleKey, $injuryKey):string
101
    {
102
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'injuries', $injuryKey, 'name']);
103
    }
104
105
    /**
106
     * @param $ruleKey
107
     * @param $injuryKey
108
     * @return string
109
     */
110
    public static function getInjuryEffect($ruleKey, $injuryKey):string
111
    {
112
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'injuries', $injuryKey, 'effect']);
113
    }
114
115
    /**
116
     * @param $ruleKey
117
     * @param $injuryKey
118
     * @return string
119
     */
120
    public static function getInducementName($ruleKey, $inducementKey):string
121
    {
122
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'inducements', $inducementKey]);
123
    }
124
    public static function getInducementTitle($ruleKey):string
125
    {
126
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'inducements', 'title']);
127
    }
128
    public static function getMercenaryTitle($ruleKey):string
129
    {
130
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'mercenary', 'title']);
131
    }
132
    /**
133
     * @param $ruleKey
134
     * @param $injuryKey
135
     * @return string
136
     */
137
    public static function getStarPlayerName($ruleKey, $starPlayerKey):string
138
    {
139
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'star_players', $starPlayerKey, 'name']);
140
    }
141
    public static function getStarPlayerTitle($ruleKey):string
142
    {
143
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'star_players', 'title']);
144
    }
145
146
    /***************
147
     * TEAM METHODS
148
     **************/
149
150
    /**
151
     * @param Team $team
152
     * @return string
153
     */
154
    public static function getRosterNameFor(Team $team):string
155
    {
156
        return self::getRosterKey($team->getRule()->getRuleKey(), $team->getRoster());
157
    }
158
159
    public static function getPlayerTranslationKey(Player $player):string
160
    {
161
        list($ruleKey, $type, $position) = explode(self::TRANSLATION_GLUE, $player->getType());
162
        if ($type == 'star_players') {
163
            return self::getStarPlayerName($ruleKey, $position);
164
        }
165
        return self::getPlayerKeyType($ruleKey, $type, $position);
166
    }
167
168
    public static function getPlayerKeyType($ruleKey, $roster, $type):string
169
    {
170
        return join(self::TRANSLATION_GLUE, [$ruleKey, 'rosters', $roster, 'positions', $type]);
171
    }
172
}
173