Cancelled
Push — master ( 706ba7...b281b4 )
by Paul
02:38
created
plugin/Modules/Console.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -29,37 +29,37 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function classes(): string
31 31
     {
32
-        $errno = array_unique(wp_list_pluck($this->entries, 'errno'));
33
-        if (in_array(E_ERROR, $errno)) {
34
-            return sprintf('%s glbb-error', $this->id());
32
+        $errno = array_unique( wp_list_pluck( $this->entries, 'errno' ) );
33
+        if( in_array( E_ERROR, $errno ) ) {
34
+            return sprintf( '%s glbb-error', $this->id() );
35 35
         }
36
-        if (in_array(E_WARNING, $errno)) {
37
-            return sprintf('%s glbb-warning', $this->id());
36
+        if( in_array( E_WARNING, $errno ) ) {
37
+            return sprintf( '%s glbb-warning', $this->id() );
38 38
         }
39 39
         return $this->id();
40 40
     }
41 41
 
42 42
     public function entries(): array
43 43
     {
44
-        $entries = [];
45
-        foreach ($this->entries as $entry) {
46
-            $entry['name'] = ucfirst($entry['errname']);
47
-            if ($entry['count'] > 1) {
48
-                $entry['name'] = sprintf('%s (%s)', $entry['name'], $entry['count']);
44
+        $entries = [ ];
45
+        foreach( $this->entries as $entry ) {
46
+            $entry[ 'name' ] = ucfirst( $entry[ 'errname' ] );
47
+            if( $entry[ 'count' ] > 1 ) {
48
+                $entry[ 'name' ] = sprintf( '%s (%s)', $entry[ 'name' ], $entry[ 'count' ] );
49 49
             }
50
-            $entries[] = $entry;
50
+            $entries[ ] = $entry;
51 51
         }
52 52
         return $entries;
53 53
     }
54 54
 
55 55
     public function info(): string
56 56
     {
57
-        $counts = array_count_values(wp_list_pluck($this->entries, 'errno'));
58
-        $entryCount = count($this->entries);
59
-        if (!empty($counts[E_ERROR])) {
60
-            return sprintf('%d, %d!', $entryCount, $counts[E_ERROR]);
57
+        $counts = array_count_values( wp_list_pluck( $this->entries, 'errno' ) );
58
+        $entryCount = count( $this->entries );
59
+        if( !empty( $counts[ E_ERROR ] ) ) {
60
+            return sprintf( '%d, %d!', $entryCount, $counts[ E_ERROR ] );
61 61
         }
62
-        if ($entryCount > 0) {
62
+        if( $entryCount > 0 ) {
63 63
             return (string) $entryCount;
64 64
         }
65 65
         return '';
@@ -67,51 +67,51 @@  discard block
 block discarded – undo
67 67
 
68 68
     public function label(): string
69 69
     {
70
-        return __('Console', 'blackbar');
70
+        return __( 'Console', 'blackbar' );
71 71
     }
72 72
 
73
-    public function store(string $message, string $errno = '', string $location = ''): void
73
+    public function store( string $message, string $errno = '', string $location = '' ): void
74 74
     {
75
-        if (is_numeric($errno)) { // entry likely stored by set_error_handler()
75
+        if( is_numeric( $errno ) ) { // entry likely stored by set_error_handler()
76 76
             $errname = 'Unknown';
77
-            if (array_key_exists((int) $errno, static::ERROR_CODES)) {
78
-                $errname = static::ERROR_CODES[$errno];
77
+            if( array_key_exists( (int) $errno, static::ERROR_CODES ) ) {
78
+                $errname = static::ERROR_CODES[ $errno ];
79 79
             }
80 80
         } else { // entry likely stored by filter hook
81 81
             $errname = 'Debug';
82
-            if (array_key_exists($errno, static::MAPPED_ERROR_CODES)) {
82
+            if( array_key_exists( $errno, static::MAPPED_ERROR_CODES ) ) {
83 83
                 $errname = $errno;
84
-                $errno = static::MAPPED_ERROR_CODES[$errno];
84
+                $errno = static::MAPPED_ERROR_CODES[ $errno ];
85 85
             }
86 86
         }
87
-        $errname = strtolower($errname);
88
-        $hash = md5($errno.$errname.$message.$location);
89
-        if (array_key_exists($hash, $this->entries)) {
90
-            ++$this->entries[$hash]['count'];
87
+        $errname = strtolower( $errname );
88
+        $hash = md5( $errno . $errname . $message . $location );
89
+        if( array_key_exists( $hash, $this->entries ) ) {
90
+            ++$this->entries[ $hash ][ 'count' ];
91 91
         } else {
92
-            $this->entries[$hash] = [
92
+            $this->entries[ $hash ] = [
93 93
                 'count' => 0,
94 94
                 'errname' => $errname,
95 95
                 'errno' => (int) $errno,
96
-                'message' => $this->normalizeMessage($message, $location),
96
+                'message' => $this->normalizeMessage( $message, $location ),
97 97
             ];
98 98
         }
99 99
     }
100 100
 
101
-    protected function normalizeMessage($message, string $location): string
101
+    protected function normalizeMessage( $message, string $location ): string
102 102
     {
103
-        if ($message instanceof \DateTime) {
104
-            $message = $message->format('Y-m-d H:i:s');
105
-        } elseif (is_object($message) || is_array($message)) {
106
-            $message = (new Dump())->dump($message);
103
+        if( $message instanceof \DateTime ) {
104
+            $message = $message->format( 'Y-m-d H:i:s' );
105
+        } elseif( is_object( $message ) || is_array( $message ) ) {
106
+            $message = ( new Dump() )->dump( $message );
107 107
         } else {
108
-            $message = esc_html(trim((string) $message));
108
+            $message = esc_html( trim( (string) $message ) );
109 109
         }
110
-        $location = trim($location);
111
-        if (!empty($location)) {
112
-            $location = str_replace([WP_CONTENT_DIR, ABSPATH], '', $location);
113
-            $location = sprintf('[%s]', $location);
110
+        $location = trim( $location );
111
+        if( !empty( $location ) ) {
112
+            $location = str_replace( [ WP_CONTENT_DIR, ABSPATH ], '', $location );
113
+            $location = sprintf( '[%s]', $location );
114 114
         }
115
-        return trim(sprintf('%s %s', $location, $message));
115
+        return trim( sprintf( '%s %s', $location, $message ) );
116 116
     }
117 117
 }
Please login to merge, or discard this patch.