BlockquoteConverter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toHtml() 0 17 3
A matches() 0 4 1
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