1: <?php
2:
3: namespace Deimos\Request\Adapter;
4:
5: /**
6: * Class data
7: *
8: * @package Deimos\data\Adapter
9: *
10: * @method int dataInt(string $path = null, mixed $default = 0, bool $strip = true)
11: * @method float dataFloat(string $path = null, mixed $default = 0.0, bool $strip = true)
12: * @method bool dataBool(string $path = null, mixed $default = false, bool $strip = true)
13: * @method string dataEmail(string $path = null, mixed $default = '', bool $strip = true)
14: * @method string dataIP(string $path = null, mixed $default = '', bool $strip = true)
15: * @method string dataURL(string $path = null, mixed $default = '', bool $strip = true)
16: * @method mixed dataUnsafe(string $path = null, mixed $default = '')
17: *
18: * @method int postInt(string $path = null, mixed $default = 0, bool $strip = true)
19: * @method float postFloat(string $path = null, mixed $default = 0.0, bool $strip = true)
20: * @method bool postBool(string $path = null, mixed $default = false, bool $strip = true)
21: * @method string postEmail(string $path = null, mixed $default = '', bool $strip = true)
22: * @method string postIP(string $path = null, mixed $default = '', bool $strip = true)
23: * @method string postURL(string $path = null, mixed $default = '', bool $strip = true)
24: * @method mixed postUnsafe(string $path = null, mixed $default = '')
25: */
26: trait Data
27: {
28:
29: private $dataData;
30:
31: /**
32: * @param string $path
33: * @param mixed $default
34: * @param bool $strip
35: *
36: * @return mixed
37: */
38: public function post($path = null, $default = null, $strip = true)
39: {
40: return $this->data($path, $default, $strip);
41: }
42:
43: /**
44: * @param string $path
45: * @param mixed $default
46: * @param bool $strip
47: *
48: * @return mixed
49: */
50: public function data($path = null, $default = null, $strip = true)
51: {
52: return $this->arrGetXss($this->dataData(), $path, $default, $strip);
53: }
54:
55: /**
56: * @return array
57: */
58: private function dataData()
59: {
60: if (!$this->dataData)
61: {
62: $this->dataData = $this->inputArray(INPUT_POST);
63: }
64:
65: return $this->dataData;
66: }
67:
68: /**
69: * @param string $path
70: * @param bool $strip
71: *
72: * @return mixed
73: * @throws \Deimos\Helper\Exceptions\ExceptionEmpty
74: */
75: public function postRequired($path, $strip = true)
76: {
77: return $this->dataRequired($path, $strip);
78: }
79:
80: /**
81: * @param string $path
82: * @param bool $strip
83: *
84: * @return mixed
85: * @throws \Deimos\Helper\Exceptions\ExceptionEmpty
86: */
87: public function dataRequired($path, $strip = true)
88: {
89: return $this->arrRequired($this->dataData(), $path, $strip);
90: }
91:
92: }