BlockquoteConverter::toHtml()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
ccs 10
cts 10
cp 1
rs 9.4285
cc 3
eloc 9
nc 2
nop 1
crap 3
1
<?php
2
3
namespace Sioen\JsonToHtml;
4
5
use \Michelf\Markdown;
6
7
final class BlockquoteConverter implements Converter
8
{
9 1
    public function toHtml(array $data)
10
    {
11 1
        $text = $data['text'];
12 1
        $html = '<blockquote>';
13 1
        $html .= Markdown::defaultTransform($text);
14
15
        // Add the cite if necessary
16 1
        if (isset($data['cite']) && !empty($data['cite'])) {
17
            // remove the indent thats added by Sir Trevor
18 1
            $cite = ltrim($data['cite'], '>');
19 1
            $html .= '<cite>' . Markdown::defaultTransform($cite) . '</cite>';
20 1
        }
21
22 1
        $html .= '</blockquote>';
23
24 1
        return $html;
25
    }
26
27 1
    public function matches($type)
28
    {
29 1
        return $type === 'quote';
30
    }
31
}
32