EmptyValue   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
eloc 6
c 2
b 1
f 0
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A format() 0 7 2
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace FSi\Bundle\AdminBundle\Display\Property\Formatter;
13
14
use FSi\Bundle\AdminBundle\Display\Property\ValueFormatter;
15
16
class EmptyValue implements ValueFormatter
17
{
18
    /**
19
     * @var string
20
     */
21
    private $emptyValue;
22
23
    /**
24
     * @param string $emptyValue
25
     */
26
    public function __construct(string $emptyValue = '-')
27
    {
28
        $this->emptyValue = $emptyValue;
29
    }
30
31
    /**
32
     * @param mixed $value
33
     * @return mixed
34
     */
35
    public function format($value)
36
    {
37
        if (empty($value)) {
38
            return $this->emptyValue;
39
        }
40
41
        return $value;
42
    }
43
}
44