1 | <?php |
||
14 | class Style |
||
15 | { |
||
16 | /** |
||
17 | * Container element used to inject dump into, usually pre elemnt with some styling. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $container = '<pre style="background-color: white; font-family: monospace;">{dump}</pre>'; |
||
22 | |||
23 | /** |
||
24 | * Every dumped element is wrapped using this pattern. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $element = '<span style="{style};">{element}</span>'; |
||
29 | |||
30 | /** |
||
31 | * Default indent string. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $indent = '· '; |
||
36 | |||
37 | /** |
||
38 | * Set of styles associated with different dumping properties. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $styles = [ |
||
43 | 'common' => 'color: black', |
||
44 | 'name' => 'color: black', |
||
45 | 'dynamic' => 'color: purple;', |
||
46 | 'maxLevel' => 'color: #ff9900', |
||
47 | 'syntax' => [ |
||
48 | 'common' => 'color: #666', |
||
49 | '[' => 'color: black', |
||
50 | ']' => 'color: black', |
||
51 | '(' => 'color: black', |
||
52 | ')' => 'color: black', |
||
53 | ], |
||
54 | 'value' => [ |
||
55 | 'string' => 'color: green', |
||
56 | 'integer' => 'color: red', |
||
57 | 'double' => 'color: red', |
||
58 | 'boolean' => 'color: purple; font-weight: bold;', |
||
59 | ], |
||
60 | 'type' => [ |
||
61 | 'common' => 'color: #666', |
||
62 | 'object' => 'color: #333', |
||
63 | 'array' => 'color: #333', |
||
64 | 'null' => 'color: #666; font-weight: bold;', |
||
65 | 'resource' => 'color: #666; font-weight: bold;', |
||
66 | ], |
||
67 | 'access' => [ |
||
68 | 'common' => 'color: #666', |
||
69 | 'public' => 'color: #8dc17d', |
||
70 | 'private' => 'color: #c18c7d', |
||
71 | 'protected' => 'color: #7d95c1', |
||
72 | ], |
||
73 | ]; |
||
74 | |||
75 | /** |
||
76 | * Inject dumped value into dump container. |
||
77 | * |
||
78 | * @param string $dump |
||
79 | * |
||
80 | * @return string |
||
81 | */ |
||
82 | 11 | public function wrapContainer(string $dump): string |
|
86 | |||
87 | /** |
||
88 | * Set indent to line based on it's level. |
||
89 | * |
||
90 | * @param int $level |
||
91 | * |
||
92 | * @return string |
||
93 | */ |
||
94 | 11 | public function indent(int $level): string |
|
102 | |||
103 | /** |
||
104 | * Stylize content using pre-defined style. |
||
105 | * |
||
106 | * @param string|null $element |
||
107 | * @param string $type |
||
108 | * @param string $context |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | 11 | public function apply($element, string $type, string $context = ''): string |
|
123 | |||
124 | /** |
||
125 | * Get valid stype based on type and context/. |
||
126 | * |
||
127 | * @param string $type |
||
128 | * @param string $context |
||
129 | * |
||
130 | * @return string |
||
131 | */ |
||
132 | 11 | private function getStyle(string $type, string $context): string |
|
148 | } |
||
149 |