forked from phalcon/incubator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathError.php
76 lines (71 loc) · 2.44 KB
/
Error.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/*
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2016 Phalcon Team (http://www.phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to [email protected] so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <[email protected]> |
| Eduar Carvajal <[email protected]> |
| Nikita Vershinin <[email protected]> |
+------------------------------------------------------------------------+
*/
namespace Phalcon\Error;
/**
* Class Error
* @package Phalcon\Error
*
* @method int type()
* @method string message()
* @method string file()
* @method string line()
* @method \Exception exception()
* @method bool isException()
* @method bool isError()
*/
class Error
{
/**
* @var array
*/
protected $attributes;
/**
* Class constructor sets the attributes.
*
* @param array $options
*/
public function __construct(array $options = [])
{
$defaults = [
'type' => -1,
'message' => 'No error message',
'file' => '',
'line' => '',
'exception' => null,
'isException' => false,
'isError' => false,
];
$options = array_merge($defaults, $options);
foreach ($options as $option => $value) {
$this->attributes[$option] = $value;
}
}
/**
* Magic method to retrieve the attributes.
*
* @param string $method
* @param array $args
* @return mixed
*/
public function __call($method, $args)
{
return isset($this->attributes[$method]) ? $this->attributes[$method] : null;
}
}