for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Deferred
*
* Run callback when script execution is stopped.
* @package core
* @author [email protected]
* @copyright Caffeina srl - 2016 - http://caffeina.com
*/
class Deferred {
protected $callback,
$enabled = true;
public function __construct( callable $callback ) {
$this->callback = $callback;
}
public function disarm() {
$this->enabled = false;
public function prime() {
$this->enabled = true;
public function __destruct() {
if ( $this->enabled ) call_user_func( $this->callback );