1 | <?php |
||
14 | class Console |
||
15 | { |
||
16 | |||
17 | /** @var array */ |
||
18 | protected $log = array(); |
||
19 | |||
20 | /** @var array */ |
||
21 | protected $memory = array(); |
||
22 | |||
23 | /** @var array */ |
||
24 | protected $error = array(); |
||
25 | |||
26 | /** @var array */ |
||
27 | protected $speed = array(); |
||
28 | |||
29 | /** |
||
30 | * Logs data to the console |
||
31 | * Accepts any data type |
||
32 | * |
||
33 | * @param mixed $data |
||
34 | */ |
||
35 | public function log($data) |
||
39 | |||
40 | /** |
||
41 | * Logs memory usage of a variable |
||
42 | * If no parameter is passed in, logs current memory usage |
||
43 | * |
||
44 | * @param mixed $object |
||
45 | * @param string $name |
||
46 | */ |
||
47 | public function logMemory($object = null, $name = '') |
||
62 | |||
63 | /** |
||
64 | * Logs exception with optional message override |
||
65 | * |
||
66 | * @param Exception $exception |
||
67 | * @param string $message |
||
68 | */ |
||
69 | public function logError(Exception $exception, $message = '') |
||
81 | |||
82 | /** |
||
83 | * Logs current time with optional message |
||
84 | * |
||
85 | * @param string $name |
||
86 | */ |
||
87 | public function logSpeed($name = 'Point in Time') |
||
94 | |||
95 | /** |
||
96 | * Returns the collected logs |
||
97 | * |
||
98 | * @returns array |
||
99 | */ |
||
100 | public function getLogs() |
||
109 | } |
||
110 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: