Passed
Push — master ( 25c805...999286 )
by Andy
02:56 queued 11s
created

DateTimeNormalizer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Palmtree\Csv\Normalizer;
4
5
class DateTimeNormalizer extends AbstractNormalizer
6
{
7
    /** @var string */
8
    private $format = 'Y-m-d';
9
10
    public function setFormat(string $format): self
11
    {
12
        $this->format = $format;
13
14
        return $this;
15
    }
16
17
    public function getFormat(): string
18
    {
19
        return $this->format;
20
    }
21
22
    protected function getNormalizedValue(string $value): ?\DateTime
23
    {
24
        return \DateTime::createFromFormat($this->getFormat(), $value) ?: null;
25
    }
26
}
27