Welcome Guest, Not a member yet? Register   Sign In
The Request class rework
#1

(This post was last modified: 12-07-2021, 11:54 PM by iRedds.)

PHP Code:
class Request
{
    /**
    * @var array
    */
    protected $data = [];

    /**
    * Get data from collection by key and request method
    * @param string $key
    * @return mixed
    */
    public function __get(string $key){}

    /**
    * Set data for outgoing request
    * @param string $key
    * @param string $value
    */
    public function __set(string $keystring $value){}

    /**
    * Get data from collection by key and request method
    * Default value can be set
    * @param string $key
    * @param null $default
    * @return mixed
    */
    public function get(string $key$default null){}

    /**
    * Get data collection by request method
    * @return array
    */
    public function getAll(){}

    /**
    * Get data from a query string
    * @param string $key
    * @param null $default
    * @return mixed
    */
    public function query(string $key$default null){}


PHP Code:
class IncomingRequest extends Request
{
    /**
    * Disable the ability to set data for incoming requests
    */
    public function __set(string $keystring $value){ return null;}


PHP Code:
//url host/path/?a=1&b=2&c=3 with POST method a=2&b=3

echo $request->a// 2  alias for get('a'); 
echo $request->b// 3
echo $request->get('a'); // 2
echo $request->get('c'4); // 4
echo $request->getAll(); // ["a" => 2, "b" => 3]
echo $request->query('a'); // 1
echo $request->query('b'); // 2

//no more getGet, getPost, getGetPost, getPostGet, etc
//no filtering data, only raw 
Reply


Messages In This Thread
The Request class rework - by iRedds - 12-07-2021, 11:53 PM
RE: The Request class rework - by includebeer - 12-08-2021, 04:37 PM
RE: The Request class rework - by iRedds - 12-08-2021, 08:21 PM
RE: The Request class rework - by kenjis - 12-09-2021, 07:10 PM
RE: The Request class rework - by kenjis - 12-08-2021, 05:09 PM
RE: The Request class rework - by includebeer - 12-09-2021, 05:28 PM
RE: The Request class rework - by iRedds - 12-09-2021, 09:32 PM
RE: The Request class rework - by kenjis - 12-10-2021, 02:39 AM
RE: The Request class rework - by iRedds - 12-10-2021, 03:04 AM
RE: The Request class rework - by kenjis - 12-10-2021, 04:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB