Skip to content

Commit 37b5113

Browse files
committed
fix: remove instance caching for more natural flow
1 parent 5fbe69c commit 37b5113

1 file changed

Lines changed: 6 additions & 20 deletions

File tree

src/functions.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,13 @@
44

55
if (!function_exists('tick')) {
66
/**
7-
* Return the leaf date instance
8-
* @return Leaf\Date
7+
* Initialize a new date instance
8+
* @param string|DateTime $userDate The date to initialize with
9+
* @param string|null $userTimeZone The timezone to initialize with
10+
* @return \Leaf\Date
911
*/
10-
function tick(?string $userDate = null, ?string $userTimeZone = null)
12+
function tick($userDate = 'now', ?string $userTimeZone = null): \Leaf\Date
1113
{
12-
if (!class_exists('Leaf\App')) {
13-
return (new Leaf\Date())->tick($userDate, $userTimeZone);
14-
}
15-
16-
if (!(\Leaf\Config::getStatic('date'))) {
17-
\Leaf\Config::singleton('date', function () {
18-
return new \Leaf\Date();
19-
});
20-
}
21-
22-
$date = \Leaf\Config::get('date');
23-
24-
if ($userDate) {
25-
$date->tick($userDate, $userTimeZone);
26-
}
27-
28-
return $date;
14+
return (new Leaf\Date())->tick($userDate, $userTimeZone);
2915
}
3016
}

0 commit comments

Comments
 (0)