juststeveking / parameterbag
A flexible parameter bag in place of standard arrays on PHP classes
Fund package maintenance!
JustSteveKing
Installs: 201 826
Dependents: 2
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 1
Open Issues: 2
Requires
- php: ^8.0
Requires (Dev)
- pestphp/pest: ^1.8
- vimeo/psalm: ^4.8
This package is auto-updated.
Last update: 2024-11-29 05:51:32 UTC
README
A flexible parameter bag in place of standard arrays on PHP classes
Install
Via Composer
$ composer require juststeveking/parameterbag
Usage
Basic usage. Create a parameter bag from a simple array.
$parameters = ['foo' => 'bar']; $bag = new \JustSteveKing\ParameterBag($parameters);
Create a parameter bag from a query string, please note by default the delimeter is &
but this can be overridden as the second arguement should you want to use another method.
$query = \JustSteveKing\ParameterBag::fromString($request->getQuery());
A more useful example:
class Config { protected ParameterBag $items; private function __construct(array $items) { $this->items = new ParameterBag($items); } public static function create(array $items) : self { return new self($items); } }