Time   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 16.66%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 45
ccs 2
cts 12
cp 0.1666
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getCalendarModel() 0 2 1
A getAfter() 0 2 1
A getPrecision() 0 2 1
A getBefore() 0 2 1
A getTimezone() 0 2 1
A getDateTime() 0 2 1
1
<?php
2
3
namespace Samwilson\SimpleWikidata\Properties;
4
5
use DateTime;
6
use DateTimeZone;
7
use Samwilson\SimpleWikidata\Property;
8
9
/**
10
 * Literal data field for a point in time.
11
 * Given as a date and time with some precision and boundaries.
12
 * The time is saved internally in the specified calendar model.
13
 * time – explicit value for point in time, represented as a timestamp resembling ISO 8601,
14
 *  e.g. +2013-01-01T00:00:00Z. The year is always signed and padded to have between 4 and 16
15
 * digits.
16
 * timezone – explicit value as a signed integer. Timezone information as an offset from UTC in
17
 * minutes.
18
 * before – explicit integer value for how many units after the given time it could be.
19
 * The unit is given by the precision.
20
 * after – explicit integer value for how many units before the given time it could be.
21
 * The unit is given by the precision.
22
 * precision – explicit value encoded in a shortint.
23
 *     The numbers have the following meaning: 0 - billion years, 1 - hundred million years, ...,
24
 * 6 - millennium, 7 - century, 8 - decade, 9 - year, 10 - month, 11 - day, 12 - hour, 13 - minute,
25
 * 14 - second.
26
 * calendarmodel – explicit value given as a URI. It identifies the calendar model of the timestamp.
27
 */
28
class Time extends Property {
29
30
	/**
31
	 * @return DateTime
32
	 */
33 1
	public function getDateTime() {
34 1
		return new DateTime( $this->claim['mainsnak']['datavalue']['value']['time'] );
35
	}
36
37
	/**
38
	 * @return DateTimeZone
39
	 */
40
	public function getTimezone() {
41
		return new DateTimeZone( $this->claim['mainsnak']['datavalue']['value']['timezone'] );
42
	}
43
44
	/**
45
	 * @return mixed
46
	 */
47
	public function getBefore() {
48
		return $this->claim['mainsnak']['datavalue']['value']['before'];
49
	}
50
51
	/**
52
	 * @return mixed
53
	 */
54
	public function getAfter() {
55
		return $this->claim['mainsnak']['datavalue']['value']['time'];
56
	}
57
58
	/**
59
	 * @return int The numbers have the following meanings: 0 - billion years,
60
	 * 1 - hundred million years, ...,
61
	 * 6 - millennium, 7 - century, 8 - decade, 9 - year, 10 - month, 11 - day, 12 - hour,
62
	 * 13 - minute, 14 - second.
63
	 */
64
	public function getPrecision() {
65
		return $this->claim['mainsnak']['datavalue']['value']['precision'];
66
	}
67
68
	/**
69
	 * @return mixed
70
	 */
71
	public function getCalendarModel() {
72
		return $this->claim['mainsnak']['datavalue']['value']['calendarmodel'];
73
	}
74
}
75