Skip to content

Instantly share code, notes, and snippets.

@mark-gerarts
Last active December 5, 2017 18:42
Show Gist options
  • Save mark-gerarts/030b4ad315ad72c72fd23fb834f66600 to your computer and use it in GitHub Desktop.
Save mark-gerarts/030b4ad315ad72c72fd23fb834f66600 to your computer and use it in GitHub Desktop.
AutoMapper+ test case for issue #10
<?php
require 'vendor/autoload.php';
use \AutoMapperPlus\AutoMapper;
use \AutoMapperPlus\Configuration\AutoMapperConfig;
class B
{
public $x;
public function setX($x)
{
$this->x = $x;
}
}
class A extends B {}
class Dto
{
public $x;
}
$config = new AutoMapperConfig();
$config->registerMapping(A::class, Dto::class);
$mapper = new AutoMapper($config);
$a = new A;
$a->setX('Some value');
$result = $mapper->map($a, Dto::class);
echo $result->x; // => "Some value"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment