for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/* this file is part of pipelines */
namespace Ktomk\Pipelines;
/**
* catch errors w/ restore
*
* @package Ktomk\Pipelines
*/
class ErrorCatcher
{
* @var null|array
private $last;
private $previous;
* @var int
private $level;
public function __construct()
$this->start();
}
* @return ErrorCatcher
public static function create()
return new self();
* @return bool an error occured between start and end
public function end()
$this->last = error_get_last();
$error = $this->last !== $this->previous;
error_reporting($this->level);
return $error;
* start catching session (is auto-started on create)
private function start()
$this->previous = error_get_last();
$this->level = error_reporting();
error_reporting(0);