Conditions | 3 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 12 |
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 | } |
||
55 |