| 1 |
<?php |
| 2 |
|
| 3 |
namespace Illuminate\Support; |
| 4 |
|
| 5 |
use Carbon\CarbonInterface; |
| 6 |
use Carbon\CarbonInterval; |
| 7 |
use Illuminate\Support\Defer\DeferredCallback; |
| 8 |
use Illuminate\Support\Defer\DeferredCallbackCollection; |
| 9 |
use Illuminate\Support\Facades\Date; |
| 10 |
use Symfony\Component\Process\PhpExecutableFinder; |
| 11 |
|
| 12 |
if (! function_exists('Illuminate\Support\defer')) { |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
function defer(?callable $callback = null, ?string $name = null, bool $always = false): DeferredCallback|DeferredCallbackCollection |
| 22 |
{ |
| 23 |
if ($callback === null) { |
| 24 |
return app(DeferredCallbackCollection::class); |
| 25 |
} |
| 26 |
|
| 27 |
return tap( |
| 28 |
new DeferredCallback($callback, $name, $always), |
| 29 |
fn ($deferred) => app(DeferredCallbackCollection::class)[] = $deferred |
| 30 |
); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
if (! function_exists('Illuminate\Support\php_binary')) { |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
function php_binary(): string |
| 39 |
{ |
| 40 |
return (new PhpExecutableFinder)->find(false) ?: 'php'; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
if (! function_exists('Illuminate\Support\artisan_binary')) { |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
function artisan_binary(): string |
| 49 |
{ |
| 50 |
return defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan'; |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
if (! function_exists('Illuminate\Support\now')) { |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
function now($tz = null): CarbonInterface |
| 64 |
{ |
| 65 |
return Date::now(enum_value($tz)); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
if (! function_exists('Illuminate\Support\microseconds')) { |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
function microseconds(int|float $microseconds): CarbonInterval |
| 74 |
{ |
| 75 |
return CarbonInterval::microseconds($microseconds); |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
if (! function_exists('Illuminate\Support\milliseconds')) { |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
function milliseconds(int|float $milliseconds): CarbonInterval |
| 84 |
{ |
| 85 |
return CarbonInterval::milliseconds($milliseconds); |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
if (! function_exists('Illuminate\Support\seconds')) { |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
function seconds(int|float $seconds): CarbonInterval |
| 94 |
{ |
| 95 |
return CarbonInterval::seconds($seconds); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
if (! function_exists('Illuminate\Support\minutes')) { |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
function minutes(int|float $minutes): CarbonInterval |
| 104 |
{ |
| 105 |
return CarbonInterval::minutes($minutes); |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
if (! function_exists('Illuminate\Support\hours')) { |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
function hours(int|float $hours): CarbonInterval |
| 114 |
{ |
| 115 |
return CarbonInterval::hours($hours); |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
if (! function_exists('Illuminate\Support\days')) { |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
function days(int|float $days): CarbonInterval |
| 124 |
{ |
| 125 |
return CarbonInterval::days($days); |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
if (! function_exists('Illuminate\Support\weeks')) { |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
function weeks(int $weeks): CarbonInterval |
| 134 |
{ |
| 135 |
return CarbonInterval::weeks($weeks); |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
if (! function_exists('Illuminate\Support\months')) { |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
function months(int $months): CarbonInterval |
| 144 |
{ |
| 145 |
return CarbonInterval::months($months); |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
if (! function_exists('Illuminate\Support\years')) { |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
function years(int $years): CarbonInterval |
| 154 |
{ |
| 155 |
return CarbonInterval::years($years); |
| 156 |
} |
| 157 |
} |