Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mapper Build Status

Library for mapping given object to another (e.g. to DTO and back)

Usage

$registry = new MappingRegistry();
$registry->add(User::class, UserDto::class, function(User $user, MapperInterface $mapper, array $context) {
    $dto = $context[Mapper::DESTINATION_CONTEXT] ?? new UserDto();
    $dto->name = $user->getName();

    return $dto;
});

$mapper = new Mapper($registry);

$user = new User('name');
$dto = $mapper->map($user, UserDto::class);

// Map to existing object. You can get it from $context[Mapper::DESTINATION_CONTEXT]
$dto = $mapper->map($user, new UserDto());

About

Library for mapping given object to another (e.g. to DTO and back)

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages