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