Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
CanHaveTimezone | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
2 | |
0.00% |
0 / 1 |
createFromDateTimeObject | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
0 | |||
toDate | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
0 | |||
withTimezone | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | namespace Apie\DateValueObjects\Concerns; |
3 | |
4 | use DateTimeImmutable; |
5 | use DateTimeInterface; |
6 | use DateTimeZone; |
7 | |
8 | trait CanHaveTimezone |
9 | { |
10 | /** |
11 | * @see CanCreateInstanceFromDateTimeObject |
12 | */ |
13 | abstract public static function createFromDateTimeObject(DateTimeInterface $dateTime): self; |
14 | |
15 | /** |
16 | * @see IsDateValueObject |
17 | */ |
18 | abstract public function toDate(): DateTimeImmutable; |
19 | |
20 | public function withTimezone( |
21 | DateTimeZone $timezone |
22 | ): self { |
23 | $date = $this->toDate(); |
24 | return self::createFromDateTimeObject( |
25 | $date->setTimezone($timezone) |
26 | ); |
27 | } |
28 | } |