public function __construct(UserToken $userToken, DTOBuilderFactoryInterface $dtoBuilderFactory) { $this->entity = $userToken; $this->dtoBuilderFactory = $dtoBuilderFactory; $this->entityDTO = new UserTokenDTO(); $this->setId(); $this->setTime(); $this->entityDTO->userAgent = $this->entity->getUserAgent(); $this->entityDTO->ip4 = $this->entity->getIp4(); $this->entityDTO->expires = $this->entity->getExpires(); $this->entityDTO->type = $this->dtoBuilderFactory->getUserTokenTypeDTOBuilder($this->entity->getType())->build(); }