|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Twitter\Object; |
|
4
|
|
|
|
|
5
|
|
|
use Assert\Assertion; |
|
6
|
|
|
use Twitter\TwitterDatedObject; |
|
7
|
|
|
use Twitter\TwitterEventTarget; |
|
8
|
|
|
|
|
9
|
|
|
class TwitterEvent implements TwitterDatedObject |
|
10
|
|
|
{ |
|
11
|
|
|
const ACCESS_REVOKED = 'access_revoked'; |
|
12
|
|
|
const BLOCK = 'block'; |
|
13
|
|
|
const UNBLOCK = 'unblock'; |
|
14
|
|
|
const FAVORITE = 'favorite'; |
|
15
|
|
|
const UNFAVORITE = 'unfavorite'; |
|
16
|
|
|
const FOLLOW = 'follow'; |
|
17
|
|
|
const UNFOLLOW = 'unfollow'; |
|
18
|
|
|
const LIST_CREATED = 'list_created'; |
|
19
|
|
|
const LIST_DESTROYED = 'list_destroyed'; |
|
20
|
|
|
const LIST_UPDATED = 'list_updated'; |
|
21
|
|
|
const LIST_MEMBER_ADDED = 'list_member_added'; |
|
22
|
|
|
const LIST_MEMBER_REMOVED = 'list_member_removed'; |
|
23
|
|
|
const LIST_USER_SUBSCRIBED = 'list_user_subscribed'; |
|
24
|
|
|
const LIST_USER_UNSUBSCRIBED = 'list_user_unsubscribed'; |
|
25
|
|
|
const USER_UPDATED = 'user_update'; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
private $type; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var TwitterUser |
|
34
|
|
|
*/ |
|
35
|
|
|
private $source; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var TwitterUser |
|
39
|
|
|
*/ |
|
40
|
|
|
private $target; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var TwitterEventTarget |
|
44
|
|
|
*/ |
|
45
|
|
|
private $object; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var \DateTimeInterface |
|
49
|
|
|
*/ |
|
50
|
|
|
private $date; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Constructor. |
|
54
|
|
|
*/ |
|
55
|
9 |
|
public function __construct() |
|
56
|
|
|
{ |
|
57
|
9 |
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return \DateTimeInterface |
|
61
|
|
|
*/ |
|
62
|
9 |
|
public function getDate() |
|
63
|
|
|
{ |
|
64
|
9 |
|
return $this->date; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return TwitterEventTarget |
|
69
|
|
|
*/ |
|
70
|
9 |
|
public function getObject() |
|
71
|
|
|
{ |
|
72
|
9 |
|
return $this->object; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return TwitterUser |
|
77
|
|
|
*/ |
|
78
|
9 |
|
public function getSource() |
|
79
|
|
|
{ |
|
80
|
9 |
|
return $this->source; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return TwitterUser |
|
85
|
|
|
*/ |
|
86
|
9 |
|
public function getTarget() |
|
87
|
|
|
{ |
|
88
|
9 |
|
return $this->target; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return string |
|
93
|
|
|
*/ |
|
94
|
9 |
|
public function getType() |
|
95
|
|
|
{ |
|
96
|
9 |
|
return $this->type; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return string |
|
101
|
|
|
*/ |
|
102
|
3 |
|
public function __toString() |
|
103
|
|
|
{ |
|
104
|
3 |
|
return 'Event [' . $this->type . ']: ' . $this->object; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Static constructor. |
|
109
|
|
|
* |
|
110
|
|
|
* @param string $type |
|
111
|
|
|
* @param TwitterUser $source |
|
112
|
|
|
* @param TwitterUser $target |
|
113
|
|
|
* @param TwitterEventTarget $object |
|
114
|
|
|
* @param \DateTimeInterface $date |
|
115
|
|
|
* |
|
116
|
|
|
* @return TwitterEvent |
|
117
|
|
|
*/ |
|
118
|
9 |
|
public static function create( |
|
119
|
|
|
$type, |
|
120
|
|
|
TwitterUser $source, |
|
121
|
|
|
TwitterUser $target = null, |
|
122
|
|
|
TwitterEventTarget $object = null, |
|
123
|
|
|
\DateTimeInterface $date = null |
|
124
|
|
|
) { |
|
125
|
9 |
|
$obj = new self(); |
|
126
|
|
|
|
|
127
|
9 |
|
Assertion::notNull($date); |
|
128
|
9 |
|
Assertion::eq(new \DateTimeZone('UTC'), $date->getTimezone()); |
|
129
|
|
|
|
|
130
|
9 |
|
$obj->type = $type; |
|
131
|
|
|
|
|
132
|
9 |
|
$obj->source = $source; |
|
133
|
9 |
|
$obj->target = $target; |
|
134
|
9 |
|
$obj->object = $object; |
|
135
|
|
|
|
|
136
|
9 |
|
$obj->date = $date; |
|
137
|
|
|
|
|
138
|
9 |
|
return $obj; |
|
139
|
|
|
} |
|
140
|
|
|
} |
|
141
|
|
|
|