-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewer.php
More file actions
69 lines (57 loc) · 1.23 KB
/
Viewer.php
File metadata and controls
69 lines (57 loc) · 1.23 KB
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
<?php
/**
*
*/
class MdtViewer
{
private $printer;
private $settings;
public function setPrinter($printer){
$this->printer = $printer;
return $this;
}
public function updateSettings($data){
if (!is_array($data)) {
$data = [$data];
}
foreach ($data as $key => $value) {
$this->settings[$key] = $value;
}
return $this;
}
public function getSettings(){
return $this->settings;
}
public function clearSettings(){
$this->settings = [];
return $this;
}
public function __construct($printer = null, $settings = [])
{
$printer = $printer? $printer : 'noprinter';
$this->setPrinter($printer);
$this->updateSettings($settings);
}
public function noprinter($arg){
return var_export($arg, true);
}
public function json($arg){
return json_encode($arg instanceof MdtComponent ? $arg->toHash() : $arg, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
}
public function console($arg)
{
if(!is_array($arg)){
$arg = array($arg);
}
foreach ($arg as $key => $value) {
fwrite(STDOUT, $key."] ");
fwrite(STDOUT, var_export($value, true)."\n");
}
}
public function serialize($arg){
return serialize($arg);
}
public function fire($arg){
return print_r($this->{$this->printer}($arg));
}
}