GregorianCalendar::parseToDateRepresentation()   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 3
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 DateTimeImmutable;
7
use RuntimeException;
8
use DateTimeInterface;
9
use Popy\Calendar\CalendarInterface;
10
use Popy\Calendar\ValueObject\DateRepresentationInterface;
11
12
/**
13
 * Basic GregorianCalendar implementation using native php formating.
14
 */
15
class GregorianCalendar implements CalendarInterface
16
{
17
    /**
18
     * @inheritDoc
19
     */
20
    public function format(DateTimeInterface $input, $format)
21
    {
22
        return $input->format($format);
23
    }
24
25
    /**
26
     * @inheritDoc
27
     */
28
    public function formatDateRepresentation(DateRepresentationInterface $input, $format)
29
    {
30
        throw new RuntimeException('Not implemented');
31
    }
32
33
    /**
34
     * @inheritDoc
35
     */
36
    public function parse($input, $format, DateTimeZone $timezone = null)
37
    {
38
        if ($timezone !== null) {
39
            return DateTimeImmutable::createFromFormat($format, $input, $timezone) ?: null;
40
        }
41
42
        return DateTimeImmutable::createFromFormat($format, $input) ?: null;
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48
    public function parseToDateRepresentation($input, $format, DateTimeZone $timezone = null)
49
    {
50
        throw new RuntimeException('Not implemented');
51
    }
52
}
53