Total Complexity | 2 |
Total Lines | 20 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
7 | class DateFormatterDayOfYearFixedLength implements DateFormatterInterface |
||
8 | { |
||
9 | /** |
||
10 | * @param \DateTimeInterface $date |
||
11 | * @param string $format |
||
12 | * @return string |
||
13 | */ |
||
14 | 1 | public function format(\DateTimeInterface $date, $format) |
|
15 | { |
||
16 | // Clarisoft starts from 1, PHP from 0 |
||
17 | 1 | $dayOfYear = (string) $date->format('z') + 1; |
|
18 | 1 | return (string) str_pad($dayOfYear, 3, '0', STR_PAD_LEFT); |
|
19 | } |
||
20 | |||
21 | /** |
||
22 | * @return DateFormatterInterface |
||
23 | */ |
||
24 | 1 | public static function factory() |
|
27 | } |
||
28 | } |
||
29 |