Source of file Error.php
Size: 2,246 Bytes - Last Modified: 2015-12-22T09:12:14-05:00
../src/Error.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
Covered by 4 test(s):
484950
Covered by 4 test(s):
51
Covered by 4 test(s):
52
Covered by 4 test(s):
53
Covered by 4 test(s):
54
Covered by 4 test(s):
55
Covered by 4 test(s):
56
Covered by 4 test(s):
57585960
Covered by 4 test(s):
61
Covered by 4 test(s):
62
Covered by 4 test(s):
63
Covered by 4 test(s):
64
Covered by 4 test(s):
6566
Covered by 3 test(s):
676869
Covered by 1 test(s):
70
Covered by 1 test(s):
71
Covered by 1 test(s):
72737475767778798081828384
Covered by 4 test(s):
85
Covered by 4 test(s):
86878889909192939495
Covered by 1 test(s):
969798
| <?php /** * Class to handle errors throughout the site * * @category PHP * @package MvcLite * @subpackage Error * @since File available since release 1.2.x * @author Cory Collier <corycollier@corycollier.com> */ namespace MvcLite; use MvcLite\Traits\Singleton as SingletonTrait; /** * Class to handle errors throughout the site * * @category PHP * @package MvcLite * @subpackage Error * @since File available since release 1.2.x * @author Cory Collier <corycollier@corycollier.com> */ class Error extends ObjectAbstract { use SingletonTrait; /** * Holder for all the errors that have occured for the request. * * @var array $errors */ protected $errors = []; /** * handler for errors */ public static function handle( $errno, $errstr, $errfile = null, $errline = null, $errcontext = [] ) { $self = get_called_class(); // append the errors to the list of errors that have occured so far $self::getInstance()->addError([ 'errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline, 'errcontext' => $errcontext, ]); // switch, based on the error number given switch ($errno) { case E_ERROR: case E_WARNING: case E_PARSE: case E_CORE_WARNING: case E_USER_ERROR: // figure out something appropriate to do throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); // the default stuff default: return; } } /** * Adds errors to the instance's error property. * * @param array $error An array representing an error. * * @return MvcLite\Error $this for object-chaining. */ protected function addError($error = []) { $this->errors[] = $error; return $this; } /** * Getter for the errors property. * * @return array */ public function getErrors() { return $this->errors; } } |