Skip to content

Commit

Permalink
Add Result::__invoke method
Browse files Browse the repository at this point in the history
  • Loading branch information
Nofriandi Ramenta committed Jul 18, 2014
1 parent 2110422 commit 496a2e4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Dabble/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,24 @@ public function free()
return false;
}

/**
* Runs a user-provided callback with the MySQLi_Result object given as
* argument and returns the result, or returns the MySQLi_Result object if
* called without an argument.
*
* @param callable $callback User-provided callback (optional)
*
* @return mixed|MySQLi_Result
*/
public function __invoke($callback = null)
{
if (isset($callback)) {
return call_user_func($callback, $this->result);
} else {
return $this->result;
}
}

/**
* Object destructor.
*/
Expand Down

0 comments on commit 496a2e4

Please sign in to comment.