name), new EmailAddress($data->email), $data->role, EmploymentEndDate::parse($data->employmentEndsOn), $data->supervisorId, $data->moneyPermissions, ); $userId = $this->transactions->run(function () use ($user): int { if ($this->users->isEmailTaken($user->email())) { throw new EmailAlreadyInUse; } $this->supervisorRule->ensureValidFor($user); return (int) $this->users->save($user)->id(); }); return new CreatedUserAccount($userId, $this->passwordLinks->issueSetupLink($user->email())); } }