PresetFormatter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Popy\Calendar;
4
5
use DateTimeInterface;
6
7
/**
8
 * Utility/Helper class : Stores a preset date formatting to be used as a quick formatter.
9
 */
10
class PresetFormatter
11
{
12
    /**
13
     * Formatter.
14
     *
15
     * @var FormatterInterface
16
     */
17
    protected $formatter;
18
    
19
    /**
20
     * Preset format.
21
     *
22
     * @var string
23
     */
24
    protected $format;
25
26
    /**
27
     * Class constructor.
28
     *
29
     * @param FormatterInterface $formatter Formatter
30
     * @param string             $format    Date format
31
     */
32
    public function __construct(FormatterInterface $formatter, $format)
33
    {
34
        $this->formatter = $formatter;
35
        $this->format   = $format;
36
    }
37
38
    /**
39
     * Format the input date.
40
     *
41
     * @param DateTimeInterface $input
42
     *
43
     * @return string
44
     */
45
    public function format(DateTimeInterface $input)
46
    {
47
        return $this->formatter->format($input, $this->format);
48
    }
49
}
50