Total Complexity | 4 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
14 | class BlockquoteConverter implements ConverterInterface |
||
15 | { |
||
16 | /** |
||
17 | * Converts the specified element into a parsed string. |
||
18 | * |
||
19 | * @param \League\HTMLToMarkdown\ElementInterface $element |
||
20 | * @return string |
||
21 | */ |
||
22 | 3 | public function convert(ElementInterface $element) |
|
23 | { |
||
24 | // Contents should have already been converted to Markdown by this point, |
||
25 | // so we just need to add '>' symbols to each line. |
||
26 | |||
27 | 3 | $markdown = ''; |
|
28 | |||
29 | 3 | $quote = trim($element->getValue()); |
|
30 | |||
31 | 3 | $lines = preg_split('/\r\n|\r|\n/', $quote); |
|
32 | |||
33 | 3 | $total = count((array) $lines); |
|
34 | |||
35 | 3 | foreach ($lines as $i => $line) |
|
36 | { |
||
37 | 3 | $markdown .= '> ' . $line . "\n"; |
|
38 | |||
39 | 3 | $newline = $i + 1 === $total; |
|
40 | |||
41 | 3 | $newline && $markdown .= "\n"; |
|
42 | 1 | } |
|
43 | |||
44 | 3 | return "\n\n" . $markdown; |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * Returns the supported HTML tags. |
||
49 | * |
||
50 | * @return string[] |
||
51 | */ |
||
52 | 15 | public function getSupportedTags() |
|
55 | } |
||
56 | } |
||
57 |