-
Notifications
You must be signed in to change notification settings - Fork 162
/
Carbon.php
36 lines (30 loc) · 898 Bytes
/
Carbon.php
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
<?php
namespace Illuminate\Support;
use Carbon\Carbon as BaseCarbon;
use Carbon\CarbonImmutable as BaseCarbonImmutable;
use Illuminate\Support\Traits\Conditionable;
use Illuminate\Support\Traits\Dumpable;
use Ramsey\Uuid\Uuid;
use Symfony\Component\Uid\Ulid;
class Carbon extends BaseCarbon
{
use Conditionable, Dumpable;
/**
* {@inheritdoc}
*/
public static function setTestNow(mixed $testNow = null): void
{
BaseCarbon::setTestNow($testNow);
BaseCarbonImmutable::setTestNow($testNow);
}
/**
* Create a Carbon instance from a given ordered UUID or ULID.
*/
public static function createFromId(Uuid|Ulid|string $id): static
{
if (is_string($id)) {
$id = Ulid::isValid($id) ? Ulid::fromString($id) : Uuid::fromString($id);
}
return static::createFromInterface($id->getDateTime());
}
}