| Conditions | 7 |
| Paths | 8 |
| Total Lines | 14 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 7 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 37 | 101 | public function extract($httpFields, $defaultValue) |
|
| 38 | { |
||
| 39 | 101 | if (!is_array($httpFields) || !isset($httpFields[$this->offset])) { |
|
| 40 | 23 | return $defaultValue; |
|
| 41 | } |
||
| 42 | |||
| 43 | 82 | $value = $httpFields[$this->offset]; |
|
| 44 | |||
| 45 | // No default value : return the real submitted value |
||
| 46 | 82 | if ($defaultValue === null) { |
|
| 47 | 77 | return $value; |
|
| 48 | } |
||
| 49 | |||
| 50 | 5 | return $value !== '' && $value !== null && $value !== [] ? $value : $defaultValue; |
|
| 51 | } |
||
| 77 |