Question
Does this mapper allow to map object to another object when the property names differ, without creating a custom transfomer?
Example (from docs)
src/Entity/Book.php
namespace App\Entity;
class Book
{
public function __construct(
private int $id,
private string $title,
) {
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
}
src/Dto/BookDto.php
namespace App\Dto;
class BookDto
{
public string $id;
public string $name; // changed this to $name instead of $title
}
How would I map the Book::title to BookDto::name?
I was previously looking at thephpleague/object-mapper, which doesn't really suit fit my use case as it does not allow object-to-object mapping directly but I saw it uses attributes like #[MapFrom] which allows to allow for custom mapping between property names. I'm not sure if there's already something similar in this library, but maybe something similar would be nice to have (if not already).
Question
Does this mapper allow to map object to another object when the property names differ, without creating a custom transfomer?
Example (from docs)
src/Entity/Book.phpsrc/Dto/BookDto.phpHow would I map the
Book::titletoBookDto::name?I was previously looking at thephpleague/object-mapper, which doesn't really suit fit my use case as it does not allow object-to-object mapping directly but I saw it uses attributes like
#[MapFrom]which allows to allow for custom mapping between property names. I'm not sure if there's already something similar in this library, but maybe something similar would be nice to have (if not already).