ergebnis / clock
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * Copyright (c) 2018-2020 Andreas Möller
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE.md file that was distributed with this source code.
10
 *
11
 * @see https://github.com/ergebnis/clock
12
 */
13

14
namespace Ergebnis\Clock;
15

16
final class SystemClock implements Clock
17
{
18
    private $timezone;
19

20 1
    public function __construct(\DateTimeZone $timezone)
21
    {
22 1
        $this->timezone = $timezone;
23
    }
24

25 1
    public function now(): \DateTimeImmutable
26
    {
27 1
        return new \DateTimeImmutable(
28 1
            'now',
29 1
            $this->timezone
30
        );
31
    }
32

33 1
    public function freeze(): FrozenClock
34
    {
35 1
        return new FrozenClock($this->now());
36
    }
37
}

Read our documentation on viewing source code .

Loading