-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
LastEditedBy.php
51 lines (40 loc) · 1.08 KB
/
LastEditedBy.php
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
<?php
namespace Notion\Databases\Properties;
/**
* @psalm-type LastEditedByJson = array{
* id: string,
* name: string,
* type: "last_edited_by",
* last_edited_by: array<empty, empty>,
* }
*/
class LastEditedBy implements PropertyInterface
{
private const TYPE = Property::TYPE_LAST_EDITED_BY;
private Property $property;
private function __construct(Property $property)
{
$this->property = $property;
}
public static function create(string $propertyName = "LastEditedBy"): self
{
$property = Property::create("", $propertyName, self::TYPE);
return new self($property);
}
public function property(): Property
{
return $this->property;
}
public static function fromArray(array $array): self
{
/** @psalm-var LastEditedByJson $array */
$property = Property::fromArray($array);
return new self($property);
}
public function toArray(): array
{
$array = $this->property->toArray();
$array[self::TYPE] = [];
return $array;
}
}