Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
11 | public function convert(ElementInterface $element): string |
||
12 | { |
||
13 | // Contents should have already been converted to Markdown by this point, |
||
14 | 6 | // so we just need to add '>' symbols to each line. |
|
15 | |||
16 | $markdown = ''; |
||
17 | |||
18 | $quoteContent = \trim($element->getValue()); |
||
19 | 6 | ||
20 | $lines = \preg_split('/\r\n|\r|\n/', $quoteContent); |
||
21 | 6 | \assert(\is_array($lines)); |
|
22 | |||
23 | 6 | $totalLines = \count($lines); |
|
24 | |||
25 | 6 | foreach ($lines as $i => $line) { |
|
26 | $markdown .= '> ' . $line . "\n"; |
||
27 | 6 | if ($i + 1 === $totalLines) { |
|
28 | 6 | $markdown .= "\n"; |
|
29 | 6 | } |
|
30 | 6 | } |
|
31 | 4 | ||
32 | 4 | return $markdown; |
|
33 | } |
||
43 |