ComposedCalendar::format()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Popy\Calendar\Calendar;
4
5
use DateTimeZone;
6
use DateTimeInterface;
7
use Popy\Calendar\CalendarInterface;
8
use Popy\Calendar\FormatterInterface;
9
use Popy\Calendar\ParserInterface;
10
use Popy\Calendar\ValueObject\DateRepresentationInterface;
11
12
/**
13
 * Composition implementation.
14
 */
15
class ComposedCalendar implements CalendarInterface
16
{
17
    /**
18
     * Formatter
19
     *
20
     * @var FormatterInterface
21
     */
22
    protected $formatter;
23
24
    /**
25
     * Parser
26
     *
27
     * @var ParserInterface
28
     */
29
    protected $parser;
30
31
    /**
32
     * Class constructor.
33
     *
34
     * @param FormatterInterface $formatter
35
     * @param ParserInterface   $parser
36
     */
37
    public function __construct(FormatterInterface $formatter, ParserInterface $parser)
38
    {
39
        $this->formatter = $formatter;
40
        $this->parser   = $parser;
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46
    public function format(DateTimeInterface $input, $format)
47
    {
48
        return $this->formatter->format($input, $format);
49
    }
50
51
    /**
52
     * @inheritDoc
53
     */
54
    public function formatDateRepresentation(DateRepresentationInterface $input, $format)
55
    {
56
        return $this->formatter->formatDateRepresentation($input, $format);
57
    }
58
59
    /**
60
     * @inheritDoc
61
     */
62
    public function parse($input, $format, DateTimeZone $timezone = null)
63
    {
64
        return $this->parser->parse($input, $format, $timezone);
65
    }
66
    
67
    /**
68
     * @inheritDoc
69
     */
70
    public function parseToDateRepresentation($input, $format, DateTimeZone $timezone = null)
71
    {
72
        return $this->parser->parseToDateRepresentation($input, $format, $timezone);
73
    }
74
}
75