Conditions | 7 |
Paths | 7 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php namespace App\Modules\V1\Core\Traits; |
||
34 | protected function getTranslatedAttribute($key, $values) |
||
35 | { |
||
36 | $values = json_decode($values); |
||
37 | $primaryLocale = \Session::get(\CoreConfig::getConfig()['var_names']['locale']); |
||
38 | $fallbackLocale = \CoreConfig::getConfig()['var_names']['locale_fallback']; |
||
39 | |||
40 | if ($primaryLocale == 'all') |
||
41 | { |
||
42 | return $values; |
||
43 | } |
||
44 | |||
45 | if ( ! $primaryLocale || ! isset($values->$primaryLocale)) |
||
46 | { |
||
47 | return $values ? isset($values->$fallbackLocale) ? $values->$fallbackLocale : $values : ''; |
||
48 | } |
||
49 | |||
50 | return $primaryLocale == 'all' ? $values : $values->$primaryLocale; |
||
51 | } |
||
52 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: