-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
31 lines (24 loc) · 717 Bytes
/
example.php
File metadata and controls
31 lines (24 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
use App\Model\Person;
use Zolex\VOM\Serializer\Factory\VersatileObjectMapperFactory;
use Zolex\VOM\VersatileObjectMapper;
require __DIR__.'/vendor/autoload.php';
// create the VOM instance
$objectMapper = VersatileObjectMapperFactory::create();
// source data
$data = [
'firstname' => 'Jane',
'surname' => 'Doe',
'street' => 'Samplestreet 123',
'city' => 'Worsthausen',
'zip' => '12345',
'country_name' => 'United Kingdom',
'email_address' => 'jane.doe@examplemail.com',
'phone' => '0123456789',
];
// create the model instance
$person = $objectMapper->denormalize($data, Person::class);
echo "INPUT DATA:\n";
print_r($data);
echo "\n\nMAPPED MODEL:\n";
print_r($person);