| 1 | <?php |
||
| 25 | abstract class HttpRequestAbstract |
||
| 26 | { |
||
| 27 | /** @var string */ |
||
| 28 | protected $stream = 'php://input'; |
||
| 29 | protected $validator; |
||
| 30 | /** @var array Valid data */ |
||
| 31 | protected $data; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Save data after validation |
||
| 35 | * |
||
| 36 | * @param array $data |
||
| 37 | */ |
||
| 38 | protected function setData(array $data) |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Getting http-request body |
||
| 45 | * |
||
| 46 | * @return array |
||
| 47 | */ |
||
| 48 | abstract public function getBody(); |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Check input according definitions |
||
| 52 | * |
||
| 53 | * @param mixed $definitions |
||
| 54 | */ |
||
| 55 | abstract public function check($definitions); |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Setting stream for request data reading |
||
| 59 | * |
||
| 60 | * @param string $stream |
||
| 61 | */ |
||
| 62 | public function setStream($stream) |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Getting validator |
||
| 69 | * |
||
| 70 | * @return ValidatorInterface |
||
| 71 | */ |
||
| 72 | public function getValidator() |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Setting validator |
||
| 79 | * |
||
| 80 | * @param $validator |
||
| 81 | * |
||
| 82 | * @return $this |
||
| 83 | */ |
||
| 84 | public function setValidator(ValidatorInterface $validator) |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Getting valid data |
||
| 93 | * |
||
| 94 | * @param $definitions |
||
| 95 | * |
||
| 96 | * @return array |
||
| 97 | */ |
||
| 98 | public function getData($definitions) |
||
| 104 | } |
||
| 105 |