1 | <?php |
||
10 | trait Data { |
||
11 | /** |
||
12 | * Data array, similar to `$_POST` |
||
13 | * |
||
14 | * @var array |
||
15 | */ |
||
16 | public $data; |
||
17 | /** |
||
18 | * Data stream resource, similar to `fopen('php://input', 'br')` |
||
19 | * |
||
20 | * Make sure you're controlling position in stream where you read something, if code in some other place might seek on this stream |
||
21 | * |
||
22 | * Stream is read-only |
||
23 | * |
||
24 | * @var null|resource |
||
25 | */ |
||
26 | public $data_stream; |
||
27 | /** |
||
28 | * @param array $data Typically `$_POST` |
||
29 | * @param null|resource|string $data_stream String, like `php://input` or resource, like `fopen('php://input', 'br')` |
||
30 | */ |
||
31 | function init_data ($data = [], $data_stream = null) { |
||
38 | /** |
||
39 | * Get data item by name |
||
40 | * |
||
41 | * @param string|string[] $name |
||
42 | * |
||
43 | * @return false|mixed|mixed[] Data if exists or `false` otherwise |
||
44 | */ |
||
45 | function data ($name) { |
||
58 | } |
||
59 |