public function testIsNaryConsumer()
 {
     $consumer = Callables::newConsumer(function ($a, $b, $c) {
         return false;
     });
     $this->assertFalse(Callables::isUnaryConsumer($consumer));
     $this->assertFalse(Callables::isBinaryConsumer($consumer));
     $this->assertTrue(Callables::isNaryConsumer($consumer));
 }
 public function testConsumer()
 {
     $this->assertEquals(Callables::newConsumer(self::get1Ary()), Consumer(self::get1Ary()));
     $this->assertEquals(Callables::newConsumer(self::get2Ary()), Consumer(self::get2Ary()));
     $this->assertEquals(Callables::newConsumer(self::get3Ary()), Consumer(self::get3Ary()));
 }
Beispiel #3
0
/**
 * Creates a new consumer from a given callable.
 *
 * The actual instance depends on the callable's arity:
 * <ul>
 * <li>A 1-ary callable creates an unary consumer</li>
 * <li>A 2-ary callable creates a binary consumer</li>
 * <li>Otherwise a N-ary consumer is created</li>
 * </ul>
 *
 * @param callable $consumer
 *            The given callable.
 * @return ConsumerInterface
 */
function Consumer(callable $consumer) : ConsumerInterface
{
    return Callables::newConsumer($consumer);
}