Completed
Push — master ( 0972fb...ca0d04 )
by Ben
02:22
created

Base   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 7
c 3
b 1
f 2
lcom 1
cbo 1
dl 0
loc 47
ccs 12
cts 12
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A asRaw() 0 7 2
A asText() 0 8 2
A asBoolean() 0 7 3
1
<?php
2
3
namespace Benrowe\Formatter\Providers;
4
5
use Benrowe\Formatter\AbstractFormatterProvider;
6
7
/**
8
 * @package Benrowe\Formatter
9
 */
10
class Base extends AbstractFormatterProvider
11
{
12
    public $booleanFormat = ['No', 'Yes'];
13
14
    /**
15
     * Handle the raw content
16
     *
17
     * @param  mixed $value
18
     * @return mixed
19
     */
20 4
    public function asRaw($value)
21
    {
22 4
        if ($value === null) {
23 1
            return $this->nullValue;
24
        }
25 3
        return $value;
26
    }
27
28
    /**
29
     * As text
30
     *
31
     * @param  mixed $value
32
     * @return string
33
     */
34 3
    public function asText($value)
35
    {
36 3
        if ($value === null) {
37 1
            return $this->nullValue;
38
        }
39
40 2
        return htmlentities($value);
41
    }
42
43
    /**
44
     * Format the value using the boolean values
45
     *
46
     * @param  mixed $value
47
     * @return string
48
     */
49 8
    public function asBoolean($value)
50
    {
51 8
        if ($value === null) {
52 1
            return $this->nullValue;
53
        }
54 7
        return $value ? $this->booleanFormat[1] : $this->booleanFormat[0];
55
    }
56
}
57