Completed
Push — master ( 674c45...3a5716 )
by John
02:35
created

DateFormatterBasic::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
namespace Graze\CiffRenderer\DateFormatter;
4
5
use Graze\CiffRenderer\DateFormatter\DateFormatterInterface;
6
use Urbanplum\DotnetDateTime\DotnetDateTime;
7
8
class DateFormatterBasic implements DateFormatterInterface
9
{
10
    /**
11
     * @var DotnetDateTime
12
     */
13
    private $dotnetDateTime;
14
15
    /**
16
     * @param DotnetDateTime $dotnetDateTime
17
     */
18 2
    public function __construct(DotnetDateTime $dotnetDateTime)
19
    {
20 2
        $this->dotnetDateTime = $dotnetDateTime;
21 2
    }
22
23
    /**
24
     * @param \DateTimeInterface $date
25
     * @param string $format
26
     * @return string
27
     */
28 1
    public function format(\DateTimeInterface $date, $format)
29
    {
30 1
        $phpFormat = $this->dotnetDateTime->formatToPhp($format);
31 1
        return (string) $date->format($phpFormat);
32
    }
33
34
    /**
35
     * @return DateFormatterInterface
36
     */
37 1
    public static function factory()
38
    {
39 1
        return new static(
40 1
            new DotnetDateTime()
41 1
        );
42
    }
43
}
44