Skip to content

Instantly share code, notes, and snippets.

@shadowhand
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadowhand/469bbea1900969f5d7e7 to your computer and use it in GitHub Desktop.
Save shadowhand/469bbea1900969f5d7e7 to your computer and use it in GitHub Desktop.
a "user can register" use case
<?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