public function __invoke(Register $request) { $passwordHash = $this->passwordEncoder->encodePassword($request->password); if (empty($request->id)) { $id = UserId::fromString($request->email); } else { $id = $request->id; } $plan = PlanBuilder::create()->setPricingMethod(MonthlyBasedPricingMethod::create(275))->setTrialPerdiod(TrialPeriod::start())->getPlan(); var_dump($plan); exit; $user = User::register($id, new Name($request->firstName, $request->middleName, $request->lastName), new EmailAddress($request->email), $passwordHash, $plan); $this->userRepo->save($user); return new RegisterUserResponse($id); }
public static function register(UserId $userId, Name $name, EmailAddress $email, $password) { $user = new User($userId); $user->recordThat(new UserWasRegistered($userId, $name, $email, $password)); return $user; }