Repository
Source
File: vendor/phpoption/phpoption/tests/PhpOption/Tests/SomeTest.php
class Repository
{
private $users;
public function __construct(array $users = array())
{
$this->users = $users;
}
// A fast ID lookup, probably cached, sometimes we might not need the entire user.
public function getLastRegisteredUsername()
{
if (empty($this->users)) {
return \PhpOption\None::create();
}
return new Some(end($this->users));
}
// Returns a user object (we will live with an array here).
public function getUser($name)
{
if (in_array($name, $this->users, true)) {
return new Some(array('name' => $name));
}
return \PhpOption\None::create();
}
public function getDefaultUser()
{
return array('name' => 'muhuhu');
}
}