1 | <?php |
||
18 | class DebuggerDump |
||
19 | { |
||
20 | /** |
||
21 | * @var mixed Variable to dump |
||
22 | */ |
||
23 | protected $var; |
||
24 | |||
25 | /** |
||
26 | * Dump variable to debugger bar |
||
27 | * |
||
28 | * @var bool |
||
29 | */ |
||
30 | protected $toBar = false; |
||
31 | |||
32 | /** |
||
33 | * Return dump as string |
||
34 | * |
||
35 | * @var bool |
||
36 | */ |
||
37 | protected $return = false; |
||
38 | |||
39 | /** |
||
40 | * Collapse structure with length above defined |
||
41 | * |
||
42 | * @var int |
||
43 | */ |
||
44 | protected $collapse = 1; |
||
45 | |||
46 | /** |
||
47 | * Maximum structure depth |
||
48 | * |
||
49 | * @var int |
||
50 | */ |
||
51 | protected $maxDepth; |
||
52 | |||
53 | /** |
||
54 | * Maximum data length |
||
55 | * |
||
56 | * @var int |
||
57 | */ |
||
58 | protected $maxLength; |
||
59 | |||
60 | /** |
||
61 | * @param mixed $var Variable to dump |
||
62 | */ |
||
63 | public function __construct($var) |
||
67 | |||
68 | /** |
||
69 | * Return as string |
||
70 | * |
||
71 | * @param bool $return |
||
72 | * @return $this |
||
73 | */ |
||
74 | public function setReturn($return = true) |
||
79 | |||
80 | /** |
||
81 | * @param int $collapse |
||
82 | * @return $this |
||
83 | */ |
||
84 | public function setCollapse(int $collapse = 1) |
||
89 | |||
90 | /** |
||
91 | * @param int $maxDepth |
||
92 | * @return $this |
||
93 | */ |
||
94 | public function setMaxDepth(int $maxDepth) |
||
99 | |||
100 | /** |
||
101 | * @param int $maxLength |
||
102 | * @return $this |
||
103 | */ |
||
104 | public function setMaxLength(int $maxLength) |
||
109 | |||
110 | protected function getOptions() |
||
118 | |||
119 | /** |
||
120 | * Return or output a variable dump |
||
121 | * |
||
122 | * @return string|null |
||
123 | */ |
||
124 | public function dump() : ?string |
||
137 | |||
138 | /** |
||
139 | * Dump to debugger bar |
||
140 | * |
||
141 | * @param string|null $title Dump title |
||
142 | * @return $this |
||
143 | */ |
||
144 | public function bar(string $title = null) |
||
149 | |||
150 | /** |
||
151 | * Dump to PHP error log |
||
152 | * |
||
153 | * @return $this |
||
154 | */ |
||
155 | public function log() |
||
160 | |||
161 | /** |
||
162 | * @return string |
||
163 | */ |
||
164 | protected function dumpReturn() |
||
170 | |||
171 | /** |
||
172 | * @return string |
||
173 | */ |
||
174 | public function __toString() : string |
||
178 | } |
||
179 |