Cell::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
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