1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Baguette\Mastodon\Entity; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Attachment |
7
|
|
|
* |
8
|
|
|
* @author USAMI Kenta <[email protected]> |
9
|
|
|
* @copyright 2017 Baguette HQ |
10
|
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL-3.0 |
11
|
|
|
* @see https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#notification |
12
|
|
|
* @property-read int $id notification ID |
13
|
|
|
* @property-read string $type One of: "mention", "reblog", "favourite", "follow" |
14
|
|
|
* @property-read \DateTimeImmutable $created_at time the notification was created |
15
|
|
|
* @property-read Account $account The Account sending the notification to the user |
16
|
|
|
* @property-read Status $status The Status associated with the notification, if applicable |
17
|
|
|
*/ |
18
|
|
|
class Notification extends Entity |
19
|
|
|
{ |
20
|
|
|
use \Teto\Object\TypedProperty; |
21
|
|
|
|
22
|
|
|
private static $property_types = [ |
|
|
|
|
23
|
|
|
'id' => 'int', |
24
|
|
|
'type' => 'enum', |
25
|
|
|
'created_at' => \DateTimeImmutable::class, |
26
|
|
|
'account' => Account::class, |
27
|
|
|
'status' => Status::class, |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
private static $enum_values = [ |
|
|
|
|
31
|
|
|
'type' => ['mention', 'reblog', 'favourite', 'follow'], |
32
|
|
|
]; |
33
|
|
|
|
34
|
2 |
|
public function __construct(array $properties) |
35
|
|
|
{ |
36
|
2 |
|
$this->setProperties(mapValues($properties, [ |
37
|
2 |
|
'created_at' =>\DateTimeImmutable::class, |
38
|
|
|
'account' =>Account::class, |
39
|
|
|
'status' =>Status::class, |
40
|
|
|
])); |
41
|
2 |
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Returns notification data as array |
45
|
|
|
* |
46
|
|
|
* @return array |
47
|
|
|
*/ |
48
|
2 |
|
public function toArray() |
49
|
|
|
{ |
50
|
|
|
return [ |
51
|
2 |
|
'id' => $this->id, |
52
|
2 |
|
'type' => $this->type, |
53
|
2 |
|
'created_at' => toArrayValue($this->created_at), |
54
|
2 |
|
'account' => toArrayValue($this->account), |
55
|
2 |
|
'status' => toArrayValue($this->status), |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.