1 | <?php |
||
6 | class Event |
||
7 | { |
||
8 | public $raw = ''; |
||
9 | protected $signature = ''; |
||
10 | public $obj; |
||
11 | const SIGNATURE_KEY = 'HTTP_X_PAYSTACK_SIGNATURE'; |
||
12 | |||
13 | 6 | protected function __construct() |
|
16 | |||
17 | 3 | public static function capture() |
|
|
|||
18 | { |
||
19 | 3 | $evt = new Event(); |
|
20 | 2 | $evt->raw = @file_get_contents('php://input'); |
|
21 | 2 | $evt->signature = ( isset($_SERVER[self::SIGNATURE_KEY]) ? $_SERVER[self::SIGNATURE_KEY] : '' ); |
|
22 | 2 | $evt->loadObject(); |
|
23 | 2 | return $evt; |
|
24 | } |
||
25 | |||
26 | 6 | protected function loadObject() |
|
30 | |||
31 | 1 | public function discoverOwner(array $keys) |
|
42 | |||
43 | 2 | public function validFor($key) |
|
50 | |||
51 | 2 | public function package(array $additional_headers = [], $method = 'POST') |
|
61 | |||
62 | 1 | public function forwardTo($url, array $additional_headers = [], $method = 'POST') |
|
71 | } |
||
72 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: