Пример #1
0
 public function testToList()
 {
     $just = Maybe\Maybe(10);
     $nothing = Maybe\Maybe(null);
     $this->assertEquals([10], $just->toList());
     $this->assertEquals([], $nothing->toList());
 }
Пример #2
0
 public function hello($def = 'Unknown')
 {
     $user = new User(Maybe\Maybe($this->name)->fromMaybe($def));
     return sprintf('Hello, %s', $user->getName());
 }
Пример #3
0
 public function findByName($name, User $def = null)
 {
     $user = $this->em->find(User::class, $name);
     return Maybe\Maybe($user)->fromMaybe($def ?: new User('None'));
 }