necronru / type-converter
Installs: 237
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/necronru/type-converter
Requires
- php: >=7.1
- psr/cache: ^1.0
- psr/log: ^1.0
- symfony/property-info: ^3.3
Requires (Dev)
- aviat/banker: ^1.0
- monolog/monolog: ^1.23
- phpunit/phpunit: ^6.4
- symfony/stopwatch: ^3.3
- symfony/var-dumper: ^3.3
Suggests
- aviat/banker: implementation for psr-6/cache
This package is not auto-updated.
Last update: 2025-10-18 06:40:56 UTC
README
Usage
class Awesome { public function getInt(): int {} public function getBool(): bool {} public function getString(): string {} public function getFloat(): float {} public function getAwesomes(): array {} public function addAwesome(Awesome $awesome) {} // symfony property access mutator, needs for arrayOf recognize } $converter = (new Necronru\TypeConverter\TypeConverterBuilder())->build(); $data = [ 'int' => "1", 'bool' => 'true', 'string' => 1, 'awesomes' => [ [ 'int' => "1", 'bool' => 'true', 'string' => 1, ] ] ]; var_export($converter->convert($data, Awesome::class));
Result:
array (
'int' => 1,
'bool' => true,
'string' => '1',
'awesomes' =>
array (
0 =>
array (
'int' => 1,
'bool' => true,
'string' => '1',
),
),
);