-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGovProperty.php
More file actions
91 lines (72 loc) · 2.02 KB
/
GovProperty.php
File metadata and controls
91 lines (72 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
namespace Cissee\Webtrees\Module\Gov4Webtrees;
use Cissee\Webtrees\Module\Gov4Webtrees\Model\JulianDayInterval;
class GovProperty extends ResolvedProperty {
private $key;
private $govId;
private $prop;
private $language;
private $from;
private $to;
private $sticky;
public function getKey(): int {
return $this->key;
}
public function getGovId(): string {
return $this->govId;
}
public function getProp() {
return $this->prop;
}
public function getLanguage(): ?string {
return $this->language;
}
public function getFrom(): ?int {
return $this->from;
}
//exclusively!
public function getTo(): ?int {
return $this->to;
}
public function getInterval(): JulianDayInterval {
return new JulianDayInterval($this->from, $this->to);
}
public function getSticky(): bool {
return $this->sticky;
}
public function __construct(
int $key,
string $govId,
$prop,
?string $language,
?int $from,
?int $to,
bool $sticky) {
parent::__construct($prop, $sticky);
if ($from !== null) {
if ($to <= $from) {
//invalid, ignore!
$to = null;
}
}
$this->key = $key;
$this->govId = $govId;
$this->prop = $prop;
$this->language = $language;
$this->from = $from;
$this->to = $to;
$this->sticky = $sticky;
}
public function toString() {
$str = " " . $this->getProp();
if ($this->getFrom() != null) {
$ymd = cal_from_jd($this->getFrom(), CAL_GREGORIAN);
$str .= " (from " . $ymd["year"] . "-" . $ymd["month"] . "-" . $ymd["day"] . ")";
}
if ($this->getTo() != null) {
$ymd = cal_from_jd($this->getTo(), CAL_GREGORIAN);
$str .= " (to " . $ymd["year"] . "-" . $ymd["month"] . "-" . $ymd["day"] . ")";
}
return $str;
}
}