GregorianCalendar   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 7

4 Methods

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