PHP code example of fastnorth / property-mapper

1. Go to this page and download the library: Download fastnorth/property-mapper 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/ */

    

fastnorth / property-mapper example snippets




use FastNorth\PropertyMapper\Map;

$map = new Map;
$map
    ->map('someProperty', 'toAnotherProperty');
    ->map('yetAnotherProperty', 'toSomethingElse');



use FastNorth\PropertyMapper\Map;

// $map = ...;

$objectOne = new ClassOne;
$objectTwo = new ClassTwo;

$mapper = new Mapper;

// Applies the map, taking properties from $objectOne and applying them to $objectTwo
$mapper->process($objectOne, $objectTwo, $map);



// Applies the map in reverse, taking properties from $objectTwo and applying them to $objectOne
$mapper->reverse($objectOne, $objectTwo, $map);



use FastNorth\PropertyMapper\Map;
use FastNorth\PropertyMapper\Transformer\Datetime\StringToDateTime;

$map = new Map;
$map->map('aStringDateProperty', 'aDateTimeProperty', new DateTimeTransformer('Y-m-d'));