-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDate.php
More file actions
43 lines (34 loc) · 794 Bytes
/
Date.php
File metadata and controls
43 lines (34 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace SonsOfPHP\Component\Clock;
use Stringable;
/**
* @author Joshua Estes <joshua@sonsofphp.com>
*/
final readonly class Date implements DateInterface, Stringable
{
public function __construct(private int $year, private int $month, private int $day) {}
/**
* @see self::toString()
*/
public function __toString(): string
{
return $this->toString();
}
public function toString(): string
{
return sprintf('%d-%02d-%02d', $this->year, $this->month, $this->day);
}
public function getYear(): int
{
return $this->year;
}
public function getMonth(): int
{
return $this->month;
}
public function getDay(): int
{
return $this->day;
}
}