| Total Complexity | 6 |
| Total Lines | 85 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 2 | Features | 0 |
| 1 | <?php |
||
| 5 | class Request |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * HTTP request's data. |
||
| 9 | * |
||
| 10 | * @var array |
||
| 11 | */ |
||
| 12 | protected $requestData = []; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * HTTP POST data. |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $postData = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * HTTP GET data. |
||
| 23 | * |
||
| 24 | * @var array |
||
| 25 | */ |
||
| 26 | protected $getData = []; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Request constructor. |
||
| 30 | */ |
||
| 31 | public function __construct() |
||
| 32 | { |
||
| 33 | $this->setData(); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Set requestData, postData, getData. |
||
| 38 | * |
||
| 39 | * @return null |
||
| 40 | */ |
||
| 41 | public function setData() |
||
| 42 | { |
||
| 43 | if (config('payment.octane',false)) |
||
|
|
|||
| 44 | { |
||
| 45 | $this->requestData = request()->all(); |
||
| 46 | $this->postData = null; |
||
| 47 | $this->getData = null; |
||
| 48 | } else |
||
| 49 | { |
||
| 50 | $this->requestData = $_REQUEST; |
||
| 51 | $this->postData = $_POST; |
||
| 52 | $this->getData = $_GET; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Retrieve HTTP request data. |
||
| 58 | * |
||
| 59 | * @param string $name |
||
| 60 | * |
||
| 61 | * @return mixed|null |
||
| 62 | */ |
||
| 63 | public static function input(string $name) |
||
| 64 | { |
||
| 65 | return (new static)->requestData[$name] ?? null; |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Retrieve HTTP POST data. |
||
| 70 | * |
||
| 71 | * @param string $name |
||
| 72 | * |
||
| 73 | * @return void |
||
| 74 | */ |
||
| 75 | public static function post(string $name) |
||
| 76 | { |
||
| 77 | return (new static)->postData[$name] ?? null; |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Retrieve HTTP GET data. |
||
| 82 | * |
||
| 83 | * @param string $name |
||
| 84 | * |
||
| 85 | * @return void |
||
| 86 | */ |
||
| 87 | public static function get(string $name) |
||
| 90 | } |
||
| 91 | } |
||
| 92 |