PHP code example of necronru / type-converter
1. Go to this page and download the library: Download necronru/type-converter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
necronru / type-converter example snippets
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));