NullConverter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A convert() 0 8 2
1
<?php
2
3
/**
4
 * This file is part of plumphp/plum.
5
 *
6
 * (c) Florian Eckerstorfer <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Plum\Plum\Converter;
12
13
/**
14
 * NullConverter.
15
 *
16
 * @author    Florian Eckerstorfer <[email protected]>
17
 * @copyright 2014-2016 Florian Eckerstorfer
18
 */
19
class NullConverter implements ConverterInterface
20
{
21
    /**
22
     * @var mixed
23
     */
24
    protected $nullValue;
25
26
    /**
27
     * @param mixed $nullValue
28
     */
29 1
    public function __construct($nullValue = '')
30
    {
31 1
        $this->nullValue = $nullValue;
32 1
    }
33
34
    /**
35
     * @param mixed $item
36
     *
37
     * @return mixed
38
     */
39 2
    public function convert($item)
40
    {
41 2
        if ($item === null) {
42 2
            $item = $this->nullValue;
43 2
        }
44
45 2
        return $item;
46
    }
47
}
48