Skip to content

Request parameter manager to easily access request parameters.

Notifications You must be signed in to change notification settings

KonecnyDavid/RequestParameterManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Request Parameter manager

Request parameter manager is PHP package for object oriented way to get request (post, get) parameters. Also supports value parser to parse parameters value into format you want.

Installation:

Just require via composer

composer install thecookieshows/request-parameter-manager

Usage

RequestManager

Create new instance of RequestManager. First parameter is array of RequestParameters, second is instance of ParameterBag

$queryManager = new QueryManager([new QueryParameter('id')], $request->request);

RequestParameter

Constructor of request parameter

  1. Name of parameter
  2. Default value (default is "")
  3. Is Required (default is False)
$queryParameter = new QueryParameter('id', '1', false);

Get RequestParameterValue

$id = $queryManager->getParameterValue('id');

Set RequestParameterParser

Pass instance of parser into setParser() method

$requestParameter->setParser(new DateParser();

Create new Parser

Just implement ParserInterface

class DatetimeParser implements ParserInterface
{
    public function parse(string $input, string $format = "d-m-Y H:i:s") : \DateTime
    {
        return \DateTime::createFromFormat($format, $input);
    }
}

About

Request parameter manager to easily access request parameters.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages