1: <?php
2:
3: namespace Deimos\Request\Adapter;
4:
5: /**
6: * Class query
7: *
8: * @package Deimos\query\Adapter
9: *
10: * @method int queryInt(string $path = null, mixed $default = 0, bool $strip = true)
11: * @method float queryFloat(string $path = null, mixed $default = 0.0, bool $strip = true)
12: * @method bool queryBool(string $path = null, mixed $default = false, bool $strip = true)
13: * @method string queryEmail(string $path = null, mixed $default = '', bool $strip = true)
14: * @method string queryIP(string $path = null, mixed $default = '', bool $strip = true)
15: * @method string queryURL(string $path = null, mixed $default = '', bool $strip = true)
16: * @method mixed queryUnsafe(string $path = null, mixed $default = '')
17: *
18: * @method int getInt(string $path = null, mixed $default = 0, bool $strip = true)
19: * @method float getFloat(string $path = null, mixed $default = 0.0, bool $strip = true)
20: * @method bool getBool(string $path = null, mixed $default = false, bool $strip = true)
21: * @method string getEmail(string $path = null, mixed $default = '', bool $strip = true)
22: * @method string getIP(string $path = null, mixed $default = '', bool $strip = true)
23: * @method string getURL(string $path = null, mixed $default = '', bool $strip = true)
24: * @method mixed getUnsafe(string $path = null, mixed $default = '')
25: */
26: trait Query
27: {
28:
29: /**
30: * @var array
31: */
32: private $queryData;
33:
34: /**
35: * @param string $path
36: * @param mixed $default
37: * @param bool $strip
38: *
39: * @return mixed
40: */
41: public function get($path = null, $default = null, $strip = true)
42: {
43: return $this->query($path, $default, $strip);
44: }
45:
46: /**
47: * @param string $path
48: * @param mixed $default
49: * @param bool $strip
50: *
51: * @return mixed
52: */
53: public function query($path = null, $default = null, $strip = true)
54: {
55: return $this->arrGetXss($this->queryData(), $path, $default, $strip);
56: }
57:
58: /**
59: * @return array
60: */
61: private function queryData()
62: {
63: if (!$this->queryData)
64: {
65: $this->queryData = $this->inputArray(INPUT_GET);
66: }
67:
68: return $this->queryData;
69: }
70:
71: /**
72: * @param string $path
73: * @param bool $strip
74: *
75: * @return mixed
76: *
77: * @throws \Deimos\Helper\Exceptions\ExceptionEmpty
78: */
79: public function getRequired($path = null, $strip = true)
80: {
81: return $this->queryRequired($path, $strip);
82: }
83:
84: /**
85: * @param string $path
86: * @param bool $strip
87: *
88: * @return mixed
89: *
90: * @throws \Deimos\Helper\Exceptions\ExceptionEmpty
91: */
92: public function queryRequired($path = null, $strip = true)
93: {
94: return $this->arrRequired($this->queryData(), $path, $strip);
95: }
96:
97: }