Completed
Push — master ( eac04a...0acae1 )
by Morris
25:50 queued 09:53
created

TimeFactory::getDateTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
/**
4
 * @copyright Copyright (c) 2016, ownCloud, Inc.
5
 *
6
 * @author Bernhard Posselt <[email protected]>
7
 * @author Morris Jobke <[email protected]>
8
 * @author Thomas Müller <[email protected]>
9
 *
10
 * @license AGPL-3.0
11
 *
12
 * This code is free software: you can redistribute it and/or modify
13
 * it under the terms of the GNU Affero General Public License, version 3,
14
 * as published by the Free Software Foundation.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License, version 3,
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
23
 *
24
 */
25
26
namespace OC\AppFramework\Utility;
27
28
use OCP\AppFramework\Utility\ITimeFactory;
29
30
31
/**
32
 * Needed to mock calls to time()
33
 */
34
class TimeFactory implements ITimeFactory {
35
36
37
	/**
38
	 * @return int the result of a call to time()
39
	 */
40
	public function getTime(): int {
41
		return time();
42
	}
43
44
	/**
45
	 * @param string $time
46
	 * @param \DateTimeZone $timezone
47
	 * @return \DateTime
48
	 * @since 15.0.0
49
	 */
50
	public function getDateTime(string $time = 'now', \DateTimeZone $timezone = null): \DateTime {
51
		return new \DateTime($time, $timezone);
52
	}
53
54
}
55