1 : <?php
2 : namespace phMagick\Core;
3 : class Logger
4 : {
5 :
6 : protected $_log = array();
7 :
8 : function clear()
9 : {
10 1 : $this->_log = array();
11 1 : }
12 :
13 : function append($data)
14 : {
15 4 : $this->_log[] = $data;
16 4 : }
17 :
18 : function getAt($id)
19 : {
20 1 : if (key_exists($id, $this->_log)) {
21 1 : return $this->_log[$id];
22 : }
23 :
24 1 : return NULL;
25 : }
26 :
27 : function get()
28 : {
29 3 : return $this->_log;
30 : }
31 :
32 : /**
33 : *
34 : * @todo: revise this crap, arrays are not working properly (or the tests are screwed)
35 : *
36 : */
37 :
38 : protected function _toString($data)
39 : {
40 1 : $ret = '';
41 :
42 1 : if (!is_array($data)) {
43 1 : $data = array($data);
44 1 : }
45 :
46 1 : foreach ($data as $k => $v) {
47 :
48 1 : if (is_array($v)) {
49 0 : $ret .= $k . ":\n" . $this->_toString($v);
50 0 : } else {
51 1 : $ret .= "$v\n";
52 : }
53 :
54 1 : }
55 :
56 1 : return $ret;
57 : }
58 :
59 : function __toString()
60 : {
61 1 : $data = $this->get();
62 :
63 1 : $ret = '';
64 1 : foreach ($data as $d) {
65 1 : $ret .= $this->_toString($d);
66 1 : }
67 1 : return $ret;
68 : }
69 : }
|