Conditions | 4 |
Paths | 8 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
44 | public function getText ( string $className, string $entry, string $language = null ) : string |
||
45 | { |
||
46 | if ( empty( $language ) ) { |
||
47 | $language = $this->getLanguageFromEnvFile(); |
||
48 | } |
||
49 | |||
50 | if ( empty( $language ) ) { |
||
51 | $language = "en_US"; |
||
52 | } |
||
53 | |||
54 | $data = Yaml::parseFile( __DIR__ . sprintf( "/../../resources/Locales/translations_%s.yml", $language ) ); |
||
55 | |||
56 | $classPathParts = explode( "\\", $className ); |
||
57 | |||
58 | $dataCopy = $data; |
||
59 | |||
60 | foreach ( $classPathParts as $currentPart ) { |
||
61 | $dataCopy = $dataCopy[$currentPart]; |
||
62 | } |
||
63 | |||
64 | return $dataCopy[$entry]; |
||
65 | } |
||
67 |