wrkflow / php-get-typed-value
Get typed (strict mode) values from an Array / XML with basic validation.
Fund package maintenance!
pionl
Installs: 2 905
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 2
Open Issues: 3
Requires
- php: >=8.1
Requires (Dev)
- ext-simplexml: *
- laravel/framework: ^9.25
- nikic/php-parser: v4.17.1
- orchestra/testbench: ^7.7
- phpstan/phpstan: 1.10.38
- phpstan/phpstan-deprecation-rules: 1.1.4
- phpstan/phpstan-phpunit: 1.3.15
- phpunit/phpunit: 9.6.13
- rector/rector: 0.18.5
- symplify/easy-coding-standard: 12.0.8
Suggests
- wrkflow/larastrict: Improve your Laravel code base with DDD and strict conventions.
README
Get typed (strict mode) values from an Array / XML with basic validation.
composer require wrkflow/php-get-typed-value
Main features
- ๐ Retrieve values from Array (JSON) / XML with correct return type with safe dot notation support.
- ๐ Makes PHPStan / IDE happy due the type strict return types.
- ๐คนโ Validation: Ensures that desired value is in correct type (without additional loop validation).
- ๐ Transformers: Ensures that values are in expected type.
- โ Converts empty string values to null (can be disabled, see transformers).
use Wrkflow\GetValue\GetValue; use Wrkflow\GetValue\DataHolders\ArrayData; $data = new GetValue(new ArrayData([ 'address' => [ 'street' => [ 'number' => '13', ], 'name' => '', ] ])); $data->getInt('address.street.number') // Returns: 13 (int) $data->getString('address.street.name') // Returns: null because value does not exists $data->getRequiredString('address.street.name') // Returns: throws MissingValueForKeyException exception
Documentation
Documentation is hosted on GitHub Pages.
Comment
I've created this project as part of my mission to create work flow
tools / libraries to make my (and yours) dev
life easier and more enjoyable.
Want more tools or want to help? Check wrk-flow.com or CONTRIBUTE. You can help me improve the documentation, add new tests and features. Are you junior developer? Don't be scared, get in touch and I will guide you in your first contribution.