PluginProbe
Black Bar / 2.1.2
Black Bar v2.1.2
trunk 1.0.0 1.1.0 1.2.0 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.2.0 2.2.1 3.0.0 3.1.0 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0
blackbar / src / Console.php

Console.php in Black Bar 2.1.2, at src/Console.php

53 lines 976 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace GeminiLabs\Blackbar;
4
5 use DateTime;
6 use ReflectionClass;
7
8 class Console
9 {
10 public $entries = array();
11
12 /**
13 * @param string $message
14 * @return static
15 */
16 public function store( $message, $location = '' )
17 {
18 $this->entries[] = array(
19 'errno' => 0,
20 'message' => $location.$this->normalizeValue( $message ),
21 'name' => '<span class="glbb-info">Debug</span>',
22 );
23 return $this;
24 }
25
26 /**
27 * @param mixed $value
28 * @return bool
29 */
30 protected function isObjectOrArray( $value )
31 {
32 return is_object( $value ) || is_array( $value );
33 }
34
35 /**
36 * @param mixed $value
37 * @return string
38 */
39 protected function normalizeValue( $value )
40 {
41 if( $value instanceof DateTime ) {
42 $value = $value->format( 'Y-m-d H:i:s' );
43 }
44 else if( $this->isObjectOrArray( $value )) {
45 $value = print_r( json_decode( json_encode( $value )), true );
46 }
47 else if( is_resource( $value )) {
48 $value = (string)$value;
49 }
50 return esc_html( $value );
51 }
52 }
53