Last active
December 25, 2022 20:08
-
-
Save ismail1432/2120481d00c1de26c07b924b9c22983d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Domain; | |
final class CreateAUserHandler | |
{ | |
private UserRepositoryInterface $userRepository; | |
public function __construct(UserRepositoryInterface $userRepository) | |
{ | |
$this->userRepository = $userRepository; | |
} | |
public function execute(CreateAUserInput $input): CreateAUserOutput | |
{ | |
$user = User::create( | |
$input->getName(), | |
$input->getAge() | |
); | |
$this->userRepository->save($user); | |
return new CreateAUserOutput( | |
$user->getUserId()->getId(), | |
$user->getName(), | |
$user->getAge() | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment