111
This commit is contained in:
@@ -118,6 +118,75 @@ class Request implements RequestInterface
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $required
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function string($name, $required)
|
||||
{
|
||||
if (is_null($data = $this->post($name))) {
|
||||
if ($required) {
|
||||
throw new \Exception('Parameter is required and cannot be empty.');
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $required
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function int($name, $required)
|
||||
{
|
||||
if (is_null($data = $this->post($name))) {
|
||||
if ($required) {
|
||||
throw new \Exception('Parameter is required and cannot be empty.');
|
||||
}
|
||||
}
|
||||
return (string)$data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $required
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function float($name, $required)
|
||||
{
|
||||
if (is_null($data = $this->post($name))) {
|
||||
if ($required) {
|
||||
throw new \Exception('Parameter is required and cannot be empty.');
|
||||
}
|
||||
}
|
||||
return (float)$data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $required
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function array($name, $required)
|
||||
{
|
||||
if (is_null($data = $this->post($name))) {
|
||||
if ($required) {
|
||||
throw new \Exception('Parameter is required and cannot be empty.');
|
||||
}
|
||||
}
|
||||
if (!is_array($data)) return [];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user