wrkflow/php-get-typed-value

Get typed (strict mode) values from an Array / XML with basic validation.
6,182 2
Install
composer require wrkflow/php-get-typed-value
Latest Version:v0.9.0
PHP:>=8.3
License:MIT
Last Updated:Sep 16, 2026
Links: GitHub  ·  Packagist
Maintainer: pionl

php-get-typed-value

img php coverage

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.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

637,827,751 9,703
laravel/framework

The Laravel Framework.

589,172,971 34,950
laravel/tinker

Powerful REPL for the Laravel framework.

498,216,183 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

413,412,504 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP License
v0.9.0 >=8.3 MIT
v0.8.4 >=8.1 MIT
v0.8.3 >=8.1 MIT
v0.8.2 >=8.1 MIT
v0.8.1 >=8.1 MIT