Last active
August 29, 2015 14:00
-
-
Save shadowhand/469bbea1900969f5d7e7 to your computer and use it in GitHub Desktop.
a "user can register" use case
This file contains 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 Ushahidi\Usecase\User; | |
use Ushahidi\Entity\User; | |
use Ushahidi\Entity\UserRepository; | |
use Ushahidi\Tool\Validator; | |
class Register | |
{ | |
private $repo; | |
private $valid; | |
public function __construct(UserRepository $repo, Validator $valid) | |
{ | |
$this->repo = $repo; | |
$this->valid = $valid; | |
} | |
public function interact(User $user) | |
{ | |
$this->valid->check($user); | |
$this->repo->add($user); | |
return $user->id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment