HasRequest.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\PaymentGateways\Traits; |
| 4 | |
| 5 | trait HasRequest { |
| 6 | /** |
| 7 | * @var array |
| 8 | */ |
| 9 | private $request; |
| 10 | |
| 11 | /** |
| 12 | * @since 3.0.0 |
| 13 | * @return mixed |
| 14 | */ |
| 15 | public function get(string $key) |
| 16 | { |
| 17 | return $this->request[$key]; |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * |
| 22 | * @since 3.0.0 |
| 23 | * @return $this |
| 24 | */ |
| 25 | public function request(): self |
| 26 | { |
| 27 | $request = file_get_contents('php://input'); |
| 28 | |
| 29 | $this->request = json_decode($request, true); |
| 30 | |
| 31 | return $this; |
| 32 | } |
| 33 | } |
| 34 |