DateTimeNormalizer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 14
ccs 0
cts 5
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getNormalizedValue() 0 3 2
A format() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Palmtree\Csv\Normalizer;
6
7
class DateTimeNormalizer extends AbstractNormalizer
8
{
9
    private string $format = 'Y-m-d';
10
11
    public function format(string $format): self
12
    {
13
        $this->format = $format;
14
15
        return $this;
16
    }
17
18
    protected function getNormalizedValue(string $value): ?\DateTime
19
    {
20
        return \DateTime::createFromFormat($this->format, $value) ?: null;
21
    }
22
}
23