public function testReturnDefaultValueUsed() { $instance = new \stdClass(); $this->assertSame('defaultValue', invoke_if($instance, 'someMethod', [], 'defaultValue')); $this->assertSame($instance, invoke_if($this, 'someMethod', [], $instance)); $this->assertNull(invoke_if($this, 'someMethod', [], null)); }
<?php namespace Foo; use Functional as F; F\invoke_if(F\invoke_if($obj, 'getFoo'), 'getBar');