1 | <?php |
||
13 | class Webhook |
||
14 | { |
||
15 | /** |
||
16 | * @var EventDispatcherInterface |
||
17 | */ |
||
18 | protected $eventDispatcher; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $eventName; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $payload; |
||
29 | |||
30 | /** |
||
31 | * @var int |
||
32 | */ |
||
33 | protected $attemptCount; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $requestUuid; |
||
39 | |||
40 | /** |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $eventMap; |
||
44 | |||
45 | /** |
||
46 | * Webhook constructor. |
||
47 | * @param EventDispatcherInterface $eventDispatcher |
||
48 | */ |
||
49 | public function __construct(EventDispatcherInterface $eventDispatcher = null) |
||
54 | |||
55 | /** |
||
56 | * @param string $event |
||
57 | * @return string |
||
58 | */ |
||
59 | public function getEventClassName($event) |
||
65 | |||
66 | /** |
||
67 | * @return array |
||
68 | */ |
||
69 | public function getDefaultEventNames() |
||
91 | |||
92 | /** |
||
93 | * @return array |
||
94 | */ |
||
95 | public function getEventMap() |
||
116 | |||
117 | /** |
||
118 | * @param Request $request |
||
119 | * @return bool |
||
120 | */ |
||
121 | public function isValidRequest(Request $request) |
||
131 | |||
132 | /** |
||
133 | * @param Request $request |
||
134 | * @param bool $dispatch |
||
135 | * @return EventBase |
||
136 | * |
||
137 | * @throws \InvalidArgumentException |
||
138 | */ |
||
139 | public function parseRequest(Request $request, $dispatch = true) |
||
162 | |||
163 | /** |
||
164 | * @return array |
||
165 | */ |
||
166 | protected function getTrustedIpRanges() |
||
174 | |||
175 | /** |
||
176 | * @param Request $request |
||
177 | * @return bool |
||
178 | * |
||
179 | * @throws \InvalidArgumentException |
||
180 | */ |
||
181 | protected function checkSecurity(Request $request) |
||
209 | |||
210 | /** |
||
211 | * @param string $ip |
||
212 | * @param array $ranges |
||
213 | * @return bool |
||
214 | */ |
||
215 | protected function ipInRanges($ip, $ranges) |
||
225 | |||
226 | /** |
||
227 | * Check if a given ip is in a network |
||
228 | * @link https://gist.github.com/tott/7684443 |
||
229 | * |
||
230 | * @param string $ip IP to check in IPV4 format eg. 127.0.0.1 |
||
231 | * @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed |
||
232 | * @return boolean true if the ip is in this range / false if not. |
||
233 | */ |
||
234 | protected function ipInRange($ip, $range) |
||
245 | } |
||
246 |