| Conditions | 5 |
| Paths | 5 |
| Total Lines | 26 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php namespace PascalKleindienst\FormListGenerator\Fields; |
||
| 35 | 6 | public function getValue(array $records = []) |
|
| 36 | { |
||
| 37 | 6 | $record = $this->getRecord($records); |
|
| 38 | |||
| 39 | // Display a section |
||
| 40 | 6 | if ($this->type === 'section') { |
|
| 41 | 3 | $content = '<h2>' . $this->label . '</h2>'; |
|
| 42 | |||
| 43 | 3 | if ($this->comment) { |
|
|
|
|||
| 44 | 3 | $content .= '<p>' . $this->comment . '</p>'; |
|
| 45 | 3 | } |
|
| 46 | |||
| 47 | 3 | return $content; |
|
| 48 | } // Display a partial |
||
| 49 | 3 | elseif ($this->type === 'partial') { |
|
| 50 | // Replace ~ with root path |
||
| 51 | 3 | $this->path = str_replace('~', Config::get('root'), $this->path); |
|
| 52 | |||
| 53 | 3 | if (file_exists($this->path)) { |
|
| 54 | 3 | $value = $record; |
|
| 55 | 3 | include($this->path); |
|
| 56 | 3 | } |
|
| 57 | 3 | } |
|
| 58 | |||
| 59 | 3 | return null; |
|
| 60 | } |
||
| 61 | } |
||
| 62 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.