@@ -3,95 +3,95 @@ |
||
3 | 3 | |
4 | 4 | class ArrayDebugger extends \ArrayObject { |
5 | 5 | |
6 | - const TYPE_GET = 'GET'; |
|
7 | - const TYPE_SET = 'SET'; |
|
8 | - const TYPE_EXISTS = 'EXISTS'; |
|
9 | - const TYPE_UNSET = 'UNSET'; |
|
6 | + const TYPE_GET = 'GET'; |
|
7 | + const TYPE_SET = 'SET'; |
|
8 | + const TYPE_EXISTS = 'EXISTS'; |
|
9 | + const TYPE_UNSET = 'UNSET'; |
|
10 | 10 | |
11 | - private $logger; |
|
11 | + private $logger; |
|
12 | 12 | |
13 | - public function __construct() |
|
14 | - { |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | 15 | |
16 | - $this->logger = function($data_log) { |
|
16 | + $this->logger = function($data_log) { |
|
17 | 17 | dump($data_log); |
18 | - }; |
|
18 | + }; |
|
19 | 19 | |
20 | - call_user_func_array('parent::__construct', func_get_args()); |
|
21 | - } |
|
20 | + call_user_func_array('parent::__construct', func_get_args()); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Write log |
|
25 | - * |
|
26 | - * @param string $type |
|
27 | - * @param string $key |
|
28 | - * @param string $value |
|
29 | - * @param array $backtrace |
|
30 | - */ |
|
31 | - public function sendLog($type, $key, $value = null, array $backtrace ) |
|
32 | - { |
|
23 | + /** |
|
24 | + * Write log |
|
25 | + * |
|
26 | + * @param string $type |
|
27 | + * @param string $key |
|
28 | + * @param string $value |
|
29 | + * @param array $backtrace |
|
30 | + */ |
|
31 | + public function sendLog($type, $key, $value = null, array $backtrace ) |
|
32 | + { |
|
33 | 33 | |
34 | - $logger = $this->logger; |
|
35 | - $retorno['type'] = $type; |
|
36 | - $retorno['key'] = $key; |
|
37 | - $retorno['value'] = $value; |
|
38 | - $retorno['file'] = isset($backtrace[0]['file']) ? $backtrace[0]['file'] : ''; |
|
39 | - $retorno['line'] = isset($backtrace[0]['line']) ? $backtrace[0]['line'] : ''; |
|
40 | - return $logger($retorno); |
|
41 | - } |
|
34 | + $logger = $this->logger; |
|
35 | + $retorno['type'] = $type; |
|
36 | + $retorno['key'] = $key; |
|
37 | + $retorno['value'] = $value; |
|
38 | + $retorno['file'] = isset($backtrace[0]['file']) ? $backtrace[0]['file'] : ''; |
|
39 | + $retorno['line'] = isset($backtrace[0]['line']) ? $backtrace[0]['line'] : ''; |
|
40 | + return $logger($retorno); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Defines logger |
|
45 | - * |
|
46 | - * @param \Closure $logger |
|
47 | - */ |
|
48 | - public function setLogger(\Closure $logger) |
|
49 | - { |
|
50 | - $this->logger = $logger; |
|
51 | - } |
|
43 | + /** |
|
44 | + * Defines logger |
|
45 | + * |
|
46 | + * @param \Closure $logger |
|
47 | + */ |
|
48 | + public function setLogger(\Closure $logger) |
|
49 | + { |
|
50 | + $this->logger = $logger; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Called when getting a value from array |
|
55 | - * |
|
56 | - * @param mixed $name |
|
57 | - */ |
|
58 | - public function offsetGet($name) |
|
59 | - { |
|
60 | - $this->sendLog(static::TYPE_GET, $name, null, debug_backtrace()); |
|
61 | - return call_user_func_array('parent::offsetGet', func_get_args()); |
|
62 | - } |
|
53 | + /** |
|
54 | + * Called when getting a value from array |
|
55 | + * |
|
56 | + * @param mixed $name |
|
57 | + */ |
|
58 | + public function offsetGet($name) |
|
59 | + { |
|
60 | + $this->sendLog(static::TYPE_GET, $name, null, debug_backtrace()); |
|
61 | + return call_user_func_array('parent::offsetGet', func_get_args()); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Called when setting a value from array |
|
66 | - * |
|
67 | - * @param mixed $name |
|
68 | - * @param mixed $value |
|
69 | - */ |
|
70 | - public function offsetSet($name, $value) |
|
71 | - { |
|
72 | - $this->sendLog(static::TYPE_SET, $name, $value, debug_backtrace()); |
|
73 | - return call_user_func_array('parent::offsetSet', func_get_args()); |
|
74 | - } |
|
64 | + /** |
|
65 | + * Called when setting a value from array |
|
66 | + * |
|
67 | + * @param mixed $name |
|
68 | + * @param mixed $value |
|
69 | + */ |
|
70 | + public function offsetSet($name, $value) |
|
71 | + { |
|
72 | + $this->sendLog(static::TYPE_SET, $name, $value, debug_backtrace()); |
|
73 | + return call_user_func_array('parent::offsetSet', func_get_args()); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Called when checking a value from array |
|
78 | - * |
|
79 | - * @param mixed $name |
|
80 | - */ |
|
81 | - public function offsetExists($name) |
|
82 | - { |
|
83 | - $this->sendLog(static::TYPE_EXISTS, $name, null, debug_backtrace()); |
|
84 | - return call_user_func_array('parent::offsetExists', func_get_args()); |
|
85 | - } |
|
76 | + /** |
|
77 | + * Called when checking a value from array |
|
78 | + * |
|
79 | + * @param mixed $name |
|
80 | + */ |
|
81 | + public function offsetExists($name) |
|
82 | + { |
|
83 | + $this->sendLog(static::TYPE_EXISTS, $name, null, debug_backtrace()); |
|
84 | + return call_user_func_array('parent::offsetExists', func_get_args()); |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Called when removing a value from array |
|
89 | - * |
|
90 | - * @param mixed $name |
|
91 | - */ |
|
92 | - public function offsetUnset($name) |
|
93 | - { |
|
94 | - $this->sendLog(static::TYPE_UNSET, $name, null, debug_backtrace()); |
|
95 | - return call_user_func_array('parent::offsetUnset', func_get_args()); |
|
96 | - } |
|
87 | + /** |
|
88 | + * Called when removing a value from array |
|
89 | + * |
|
90 | + * @param mixed $name |
|
91 | + */ |
|
92 | + public function offsetUnset($name) |
|
93 | + { |
|
94 | + $this->sendLog(static::TYPE_UNSET, $name, null, debug_backtrace()); |
|
95 | + return call_user_func_array('parent::offsetUnset', func_get_args()); |
|
96 | + } |
|
97 | 97 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | * @param string $value |
29 | 29 | * @param array $backtrace |
30 | 30 | */ |
31 | - public function sendLog($type, $key, $value = null, array $backtrace ) |
|
31 | + public function sendLog($type, $key, $value = null, array $backtrace) |
|
32 | 32 | { |
33 | 33 | |
34 | 34 | $logger = $this->logger; |