ColorRenderer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handles() 0 3 1
A render() 0 9 2
A headElements() 0 3 1
1
<?php
2
namespace rtens\domin\delivery\web\renderers;
3
4
use rtens\domin\delivery\web\Element;
5
use rtens\domin\delivery\web\WebRenderer;
6
use rtens\domin\parameters\Color;
7
8
class ColorRenderer implements WebRenderer {
9
10
    /**
11
     * @param mixed $value
12
     * @return bool
13
     */
14
    public function handles($value) {
15
        return $value instanceof Color;
16
    }
17
18
    /**
19
     * @param Color $value
20
     * @return mixed
21
     */
22
    public function render($value) {
23
        if (!$value) {
24
            return null;
25
        }
26
27
        return (string)new Element('span', [
28
            'style' => 'padding: 2pt 6pt; background-color: ' . $value->asHex()
29
        ], [$value->asHex()]);
30
    }
31
32
    /**
33
     * @param mixed $value
34
     * @return array|Element[]
35
     */
36
    public function headElements($value) {
37
        return [];
38
    }
39
}