PHP 8.3.31
Preview: InteractsWithTime.php Size: 1.49 KB
/home/getspomw/royalsquad.us/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTime.php

<?php

namespace Illuminate\Foundation\Testing\Concerns;

use Illuminate\Foundation\Testing\Wormhole;
use Illuminate\Support\Carbon;

trait InteractsWithTime
{
    /**
     * Freeze time.
     *
     * @param  callable|null  $callback
     * @return mixed
     */
    public function freezeTime($callback = null)
    {
        return $this->travelTo(Carbon::now(), $callback);
    }

    /**
     * Freeze time at the beginning of the current second.
     *
     * @param  callable|null  $callback
     * @return mixed
     */
    public function freezeSecond($callback = null)
    {
        return $this->travelTo(Carbon::now()->startOfSecond(), $callback);
    }

    /**
     * Begin travelling to another time.
     *
     * @param  int  $value
     * @return \Illuminate\Foundation\Testing\Wormhole
     */
    public function travel($value)
    {
        return new Wormhole($value);
    }

    /**
     * Travel to another time.
     *
     * @param  \DateTimeInterface|\Closure|\Illuminate\Support\Carbon|string|bool|null  $date
     * @param  callable|null  $callback
     * @return mixed
     */
    public function travelTo($date, $callback = null)
    {
        Carbon::setTestNow($date);

        if ($callback) {
            return tap($callback($date), function () {
                Carbon::setTestNow();
            });
        }
    }

    /**
     * Travel back to the current time.
     *
     * @return \DateTimeInterface
     */
    public function travelBack()
    {
        return Wormhole::back();
    }
}

Directory Contents

Dirs: 0 × Files: 13

Name Size Perms Modified Actions
3.92 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
2.08 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
6.48 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
9.82 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
1.16 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
6.65 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
3.01 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
1.12 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
7.94 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
1.49 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
2.34 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
20.02 KB lrw-rw-rw- 2025-09-17 06:52:55
Edit Download
111 B lrw-rw-rw- 2025-09-17 06:52:55
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).