Cell   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 53.33%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 13
c 2
b 0
f 0
dl 0
loc 36
ccs 8
cts 15
cp 0.5333
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getRawValue() 0 3 1
A __construct() 0 4 1
A getValue() 0 3 1
A getNormalizer() 0 3 1
A __toString() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Palmtree\Csv\Cell;
6
7
use Palmtree\Csv\Normalizer\NormalizerInterface;
8
9
class Cell
10
{
11
    private NormalizerInterface $normalizer;
12
    private string $value;
13
14 13
    public function __construct(string $value, NormalizerInterface $normalizer)
15
    {
16 13
        $this->value = $value;
17 13
        $this->normalizer = $normalizer;
18 13
    }
19
20
    /** @return mixed */
21 11
    public function getValue()
22
    {
23 11
        return $this->normalizer->normalize($this->getRawValue());
24
    }
25
26 11
    public function getRawValue(): string
27
    {
28 11
        return $this->value;
29
    }
30
31
    public function getNormalizer(): NormalizerInterface
32
    {
33
        return $this->normalizer;
34
    }
35
36
    public function __toString(): string
37
    {
38
        try {
39
            $value = (string)$this->getValue();
40
        } catch (\Exception $exception) {
41
            $value = '';
42
        }
43
44
        return $value;
45
    }
46
}
47