DataSift\Storyplayer\Output::logVardump PHP Method

logVardump() public method

an alternative to using PHP's built-in var_dump()
public logVardump ( string $name, mixed $var ) : void
$name string a human-readable name to describe $var
$var mixed the variable to dump
return void
    public function logVardump($name, $var)
    {
        // enforce our inputs
        Contract::RequiresValue($name, is_string($name));
        // $var can be anything, so there is no contract to enforce
        // pass this on to our plugins
        foreach ($this->plugins as $plugin) {
            $plugin->logVardump($name, $var);
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @covers DataSift\Storyplayer\Output::logVardump()
  */
 public function testCanLogVardump()
 {
     // ----------------------------------------------------------------
     // setup the test
     $name = 'msg';
     $msg = "this is an emergency, damnit!";
     $plugin1 = Mockery::mock("DataSift\\Storyplayer\\OutputLib\\OutputPlugin");
     $plugin1->shouldReceive('logVardump')->once()->with($name, $msg);
     $plugin2 = Mockery::mock("DataSift\\Storyplayer\\OutputLib\\OutputPlugin");
     $plugin2->shouldReceive('logVardump')->once()->with($name, $msg);
     $obj = new Output();
     $obj->usePluginInSlot($plugin1, "console");
     $obj->usePluginInSlot($plugin2, "slot1");
     // ----------------------------------------------------------------
     // perform the change
     $obj->logVardump($name, $msg);
     // ----------------------------------------------------------------
     // test the results
     Mockery::close();
 }