<?php class UserService { public const USERNAME_ALREADY_TAKEN = 'username_already_taken'; /** @return Result<User, Error[]> */ public function registerUser(UserRegistrationData $data): Result { return $this->userRepository->find($data->username).mapOrElse( fn() => User::register($data->username, $this->passwordEncoder->encode($data->password))->andThen(function (User $user) { $this->userRepository->save($user); return $user; ), fn() => err([ new Error(sprintf('Username "%s" is already taken.', $data->username), self::USERNAME_ALREADY_TAKEN) ])) ); } }
You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).