DateFormatterBasic   A
last analyzed

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
use \DateTimeInterface;
8
9
class DateFormatterBasic implements DateFormatterInterface
10
{
11
    /**
12
     * @var DotnetDateTime
13
     */
14
    private $dotnetDateTime;
15
16
    /**
17
     * @param DotnetDateTime $dotnetDateTime
18
     */
19 4
    public function __construct(DotnetDateTime $dotnetDateTime)
20
    {
21 4
        $this->dotnetDateTime = $dotnetDateTime;
22 4
    }
23
24
    /**
25
     * @param DateTimeInterface $date
26
     * @param string $format
27
     * @return string
28
     */
29 2
    public function format(DateTimeInterface $date, $format)
30
    {
31 2
        $phpFormat = $this->dotnetDateTime->formatToPhp($format);
32 2
        return (string) $date->format($phpFormat);
33
    }
34
35
    /**
36
     * @return DateFormatterInterface
37
     */
38 2
    public static function factory()
39
    {
40 2
        return new static(
41 2
            new DotnetDateTime()
42
        );
43
    }
44
}
45