Skip to content

Instantly share code, notes, and snippets.

@lilobase
Created June 20, 2018 10:13
Show Gist options
  • Save lilobase/0a5af573c97e56349c9ab1e0fc3885d9 to your computer and use it in GitHub Desktop.
Save lilobase/0a5af573c97e56349c9ab1e0fc3885d9 to your computer and use it in GitHub Desktop.
namespace App\Membership\Infrastructure\Doctrine;
use App\Membership\Domain\Membership;
trait MembershipObjectMapper
{
static function fromDoctrine(MembershipDoctrineEntity $entity): Membership
{
$instance = new self();
$instance->field = $entity->field;
return $instance;
}
static function fromDomain(Membership $entity): MembershipDoctrineEntity
{
$instance = new self();
$instance->field = $entity->field();
return $instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment