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

DateFormatterBasic   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 33
rs 10
c 0
b 0
f 0
ccs 9
cts 9
cp 1
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A factory() 0 4 1
A format() 0 4 1
A __construct() 0 3 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