1: <?php
2: /*
3: * Copyright (c) 2015 @trashtoy
4: * https://github.com/trashtoy/
5: *
6: * Permission is hereby granted, free of charge, to any person obtaining a copy of
7: * this software and associated documentation files (the "Software"), to deal in
8: * the Software without restriction, including without limitation the rights to use,
9: * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
10: * Software, and to permit persons to whom the Software is furnished to do so,
11: * subject to the following conditions:
12: *
13: * The above copyright notice and this permission notice shall be included in all
14: * copies or substantial portions of the Software.
15: *
16: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18: * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19: * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20: * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21: * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22: */
23: /**
24: * PHP class file.
25: * @auhtor trashtoy
26: * @since 2.1.1
27: */
28: namespace Peach\DT;
29:
30: /**
31: * システム時刻を参照して現在時刻を生成する Clock です.
32: */
33: class DefaultClock extends Clock
34: {
35: /**
36: * このクラスは getInstance() からインスタンス化します.
37: */
38: private function __construct() {}
39:
40: /**
41: * このクラスのインスタンスを取得します.
42: * @return DefaultClock
43: * @codeCoverageIgnore
44: */
45: public static function getInstance()
46: {
47: static $instance = null;
48: if ($instance === null) {
49: $instance = new self();
50: }
51: return $instance;
52: }
53:
54: /**
55: * システム時刻を unix time に変換して, その値を返します.
56: * このメソッドの返り値は php.ini の date.timezone 設定に依存します.
57: *
58: * @return int
59: */
60: protected function getUnixTime()
61: {
62: return time();
63: }
64: }
65: