Conditions | 5 |
Paths | 5 |
Total Lines | 27 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
20 | 25 | public function get($key, array $replace = [], $locale = null, $fallback = true) |
|
21 | 8 | { |
|
22 | 9 | if (!$line = Line::findByKey($key)) { |
|
23 | |||
24 | 8 | /** |
|
25 | 2 | * If no line is requested, |
|
26 | * we check if an entire page is asked for |
||
27 | */ |
||
28 | 13 | if($page = Page::findByKey($key)) |
|
|
|||
29 | 2 | { |
|
30 | 1 | $lines = Line::getValuesByLocaleAndPage($locale, $key); |
|
31 | 1 | return ConvertToTree::fromFlattened($lines, false); |
|
32 | 8 | } |
|
33 | |||
34 | 4 | return null; |
|
35 | } |
||
36 | |||
37 | 4 | if (!$value = $line->getValue($locale, $fallback)) { |
|
38 | 1 | return null; |
|
39 | } |
||
40 | |||
41 | 4 | foreach ($replace as $key => $replacer) { |
|
42 | 1 | $value = str_replace(':'.$key, $replacer, $value); |
|
43 | } |
||
44 | |||
45 | 4 | return $value; |
|
46 | } |
||
47 | } |
||
48 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.