| Conditions | 3 |
| Paths | 2 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | public function render(History $history) |
||
| 26 | { |
||
| 27 | $this->setHistory($history); |
||
| 28 | |||
| 29 | $links = $history->getLinks(); |
||
| 30 | $hrefs = []; |
||
| 31 | $result = $this->renderObjects('renderNote', $history->getFirstTag()->getNotes()); |
||
| 32 | |||
| 33 | $result = preg_replace_callback('/\[(\S*?)\]/', function ($matches) use ($links, &$hrefs) { |
||
| 34 | if (isset($links[$matches[1]])) { |
||
| 35 | $hrefs[$matches[1]] = $links[$matches[1]]; |
||
| 36 | } |
||
| 37 | |||
| 38 | return $matches[0]; |
||
| 39 | }, $result); |
||
| 40 | |||
| 41 | if ($hrefs) { |
||
|
|
|||
| 42 | $result .= PHP_EOL . $this->renderLinks($hrefs); |
||
| 43 | } |
||
| 44 | |||
| 45 | return $result; |
||
| 46 | } |
||
| 47 | } |
||
| 48 |
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.