public function getInput(string $name, $default = null)
    {
        if ($this->isJson()) {
            $json = $this->getJsonBody();

            if (array_key_exists($name, $json)) {
                return $json[$name];
            } else {
                return $default;
            }
        } else {
            $value = null;

            switch ($this->method) {
                case RequestMethods::GET:
                    return $this->query->get($name, $default);
                case RequestMethods::POST:
                    $value = $this->post->get($name, $default);
                    break;
                case RequestMethods::DELETE:
                    $value = $this->delete->get($name, $default);
                    break;
                case RequestMethods::PUT:
                    $value = $this->put->get($name, $default);
                    break;
                case RequestMethods::PATCH:
                    $value = $this->patch->get($name, $default);
                    break;
            }

            if ($value === null) {
                // Try falling back to query
                $value = $this->query->get($name, $default);
            }

            return $value;
        }
    }
public function getInput(string $name, $default = null)
    {
        if ($this->isJson()) {
            $json = $this->getJsonBody();

            if (array_key_exists($name, $json)) {
                return $json[$name];
            } else {
                return $default;
            }
        } else {
            $value = null;

            switch ($this->method) {
                case RequestMethods::GET:
                    return $this->query->get($name, $default);
                case RequestMethods::POST:
                    $value = $this->post->get($name, $default);
                    break;
                case RequestMethods::DELETE:
                    $value = $this->delete->get($name, $default);
                    break;
                case RequestMethods::PUT:
                    $value = $this->put->get($name, $default);
                    break;
                case RequestMethods::PATCH:
                    $value = $this->patch->get($name, $default);
                    break;
            }

            if ($value === null) {
                // Try falling back to query
                $value = $this->query->get($name, $default);
            }

            return $value;
        }
    }
public function getInput ( string $ name , $ default = null ) { if ( $ this -> isJson ( ) ) { $ json = $ this -> getJsonBody ( ) ; if ( array_key_exists ( $ name , $ json ) ) { return $ json [ $ name ] ; } else { return $ default ; } } else { $ value = null ; switch ( $ this -> method ) { case RequestMethods :: GET : return $ this -> query -> get ( $ name , $ default ) ; case RequestMethods :: POST : $ value = $ this -> post -> get ( $ name , $ default ) ; break ; case RequestMethods :: DELETE : $ value = $ this -> delete -> get ( $ name , $ default ) ; break ; case RequestMethods :: PUT : $ value = $ this -> put -> get ( $ name , $ default ) ; break ; case RequestMethods :: PATCH : $ value = $ this -> patch -> get ( $ name , $ default ) ; break ; } if ( $ value === null ) { // Try falling back to query $ value = $ this -> query -> get ( $ name , $ default ) ; } return $ value ; } }
Gets the input from either GET or POST data

@param string $name The name of the input to get
@param null|mixed $default The default value to return if the input could not be found
@return mixed The value of the input if it was found, otherwise the default value
Gets the input from either GET or POST data