1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the tmilos/scim-schema package. |
5
|
|
|
* |
6
|
|
|
* (c) Milos Tomic <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Tmilos\ScimSchema\Model; |
13
|
|
|
|
14
|
|
|
use Tmilos\ScimSchema\Helper; |
15
|
|
|
|
16
|
|
|
class Meta implements SerializableInterface |
17
|
|
|
{ |
18
|
|
|
/** @var string */ |
19
|
|
|
protected $resourceType; |
20
|
|
|
|
21
|
|
|
/** @var \DateTime */ |
22
|
|
|
protected $created; |
23
|
|
|
|
24
|
|
|
/** @var \DateTime */ |
25
|
|
|
protected $lastModified; |
26
|
|
|
|
27
|
|
|
/** @var string */ |
28
|
|
|
protected $location; |
29
|
|
|
|
30
|
|
|
/** @var string */ |
31
|
|
|
protected $version; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param array $data |
35
|
|
|
* |
36
|
|
|
* @return Meta |
37
|
|
|
*/ |
38
|
|
|
public static function deserializeObject(array $data) |
39
|
|
|
{ |
40
|
|
|
$result = new static($data['resourceType'], isset($data['created']) ? Helper::string2dateTime($data['created']) : null); |
41
|
|
|
if (isset($data['lastModified'])) { |
42
|
|
|
$result->lastModified = Helper::string2dateTime($data['lastModified']); |
43
|
|
|
} |
44
|
|
|
if (isset($data['location'])) { |
45
|
|
|
$result->location = $data['location']; |
46
|
|
|
} |
47
|
|
|
if (isset($data['version'])) { |
48
|
|
|
$result->version = $data['version']; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return $result; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param string $resourceType |
56
|
|
|
* @param \DateTime $createdAt |
57
|
|
|
*/ |
58
|
|
|
public function __construct($resourceType, \DateTime $createdAt = null) |
59
|
|
|
{ |
60
|
|
|
$this->resourceType = $resourceType; |
61
|
|
|
$this->created = $createdAt; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
|
|
public function getResourceType() |
68
|
|
|
{ |
69
|
|
|
return $this->resourceType; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return \DateTime |
74
|
|
|
*/ |
75
|
|
|
public function getCreated() |
76
|
|
|
{ |
77
|
|
|
return $this->created; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return \DateTime |
82
|
|
|
*/ |
83
|
|
|
public function getLastModified() |
84
|
|
|
{ |
85
|
|
|
return $this->lastModified; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param \DateTime $lastModified |
90
|
|
|
*/ |
91
|
|
|
public function setLastModified(\DateTime $lastModified) |
92
|
|
|
{ |
93
|
|
|
$this->lastModified = $lastModified; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return string |
98
|
|
|
*/ |
99
|
|
|
public function getLocation() |
100
|
|
|
{ |
101
|
|
|
return $this->location; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param string $location |
106
|
|
|
*/ |
107
|
|
|
public function setLocation($location) |
108
|
|
|
{ |
109
|
|
|
$this->location = $location; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return string |
114
|
|
|
*/ |
115
|
|
|
public function getVersion() |
116
|
|
|
{ |
117
|
|
|
return $this->version; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param string $version |
122
|
|
|
*/ |
123
|
|
|
public function setVersion($version) |
124
|
|
|
{ |
125
|
|
|
$this->version = $version; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @return array |
130
|
|
|
*/ |
131
|
|
|
public function serializeObject() |
132
|
|
|
{ |
133
|
|
|
$result = [ |
134
|
|
|
'resourceType' => $this->resourceType, |
135
|
|
|
]; |
136
|
|
|
if ($this->created) { |
137
|
|
|
$result['created'] = Helper::dateTime2string($this->created); |
138
|
|
|
} |
139
|
|
|
if ($this->lastModified) { |
140
|
|
|
$result['lastModified'] = Helper::dateTime2string($this->lastModified); |
141
|
|
|
} |
142
|
|
|
if ($this->version) { |
143
|
|
|
$result['version'] = $this->version; |
144
|
|
|
} |
145
|
|
|
if ($this->location) { |
146
|
|
|
$result['location'] = $this->location; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
return $result; |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|