Conditions | 6 |
Paths | 9 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
26 | 16 | public function getValue() |
|
27 | { |
||
28 | 16 | if ($this->isExternal() && Url::normalizeUrl($this->value)) { |
|
29 | 2 | $value = $this->value; |
|
30 | } else { |
||
31 | 16 | $value = str_replace($this->getDomain(), '', $this->value); |
|
32 | |||
33 | 16 | if (!empty($value)) { |
|
34 | 14 | $value = $this->getDomain() . '/' . ltrim($value, '/'); |
|
35 | } else { |
||
36 | 7 | $value = null; |
|
37 | } |
||
38 | } |
||
39 | |||
40 | 16 | if (!empty($value)) { |
|
41 | 14 | $attributes = $this->getAttributes(); |
|
42 | |||
43 | 14 | if (!empty($attributes)) { |
|
44 | 2 | return [$value => $attributes]; |
|
45 | } else { |
||
46 | 14 | return $value; |
|
47 | } |
||
48 | } |
||
49 | 7 | } |
|
50 | |||
58 | } |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.