Completed
Pull Request — master (#7)
by
unknown
05:22
created

ListConverter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 17
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toHtml() 0 9 2
A matches() 0 4 1
1
<?php
2
3
namespace Sioen\JsonToHtml;
4
5
final class ListConverter implements Converter
6
{
7
    public function toHtml(array $data)
8
    {
9
        $html = '<ul>';
10
        foreach ($data['listItems'] as $listItem) {
11
            $html .= '<li>'.$listItem['content'].'</li>';
12
        }
13
        $html .= '</ul>';
14
        return $html;
15
    }
16
17
    public function matches($type)
18
    {
19
        return $type === 'list';
20
    }
21
}
22