Passed
Pull Request — master (#8)
by
unknown
10:23 queued 07:53
created
src/Profiler.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -37,33 +37,33 @@  discard block
 block discarded – undo
37 37
      * @param array $timer
38 38
      * @return string
39 39
      */
40
-    public function getMemoryString($timer)
40
+    public function getMemoryString( $timer )
41 41
     {
42
-        $timer = $this->normalize($timer);
43
-        return sprintf('%s kB', round($timer['memory'] / 1000));
42
+        $timer = $this->normalize( $timer );
43
+        return sprintf( '%s kB', round( $timer[ 'memory' ] / 1000 ) );
44 44
     }
45 45
 
46 46
     /**
47 47
      * @param array $timer
48 48
      * @return string
49 49
      */
50
-    public function getNameString($timer)
50
+    public function getNameString( $timer )
51 51
     {
52
-        $timer = $this->normalize($timer);
53
-        return $timer['name'];
52
+        $timer = $this->normalize( $timer );
53
+        return $timer[ 'name' ];
54 54
     }
55 55
 
56 56
     /**
57 57
      * @param array $timer
58 58
      * @return string
59 59
      */
60
-    public function getTimeString($timer)
60
+    public function getTimeString( $timer )
61 61
     {
62
-        $timer = $this->normalize($timer);
63
-        $index = array_search($timer['name'], array_column($this->timers, 'name'));
64
-        $start = $this->start + ($index * $this->noise);
65
-        $time = number_format(round(($timer['time'] - $start) * 1000, 4), 4);
66
-        return sprintf('%s ms', $time);
62
+        $timer = $this->normalize( $timer );
63
+        $index = array_search( $timer[ 'name' ], array_column( $this->timers, 'name' ) );
64
+        $start = $this->start + ( $index * $this->noise );
65
+        $time = number_format( round( ( $timer[ 'time' ] - $start ) * 1000, 4 ), 4 );
66
+        return sprintf( '%s ms', $time );
67 67
     }
68 68
 
69 69
     /**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function getTotalTime()
73 73
     {
74
-        $totalNoise = (count($this->timers) - 1) * $this->noise;
74
+        $totalNoise = ( count( $this->timers ) - 1 ) * $this->noise;
75 75
         return $this->stop - $this->start - $totalNoise;
76 76
     }
77 77
 
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
      * @param string $name
80 80
      * @return void
81 81
      */
82
-    public function trace($name)
82
+    public function trace( $name )
83 83
     {
84
-        $microtime = microtime(true);
85
-        if (!$this->start) {
84
+        $microtime = microtime( true );
85
+        if( !$this->start ) {
86 86
             $this->start = $microtime;
87 87
         }
88
-        if ('blackbar/profiler/noise' === $name) {
88
+        if( 'blackbar/profiler/noise' === $name ) {
89 89
             $this->noise = $microtime - $this->start;
90 90
             return;
91 91
         }
92
-        $this->timers[] = array(
92
+        $this->timers[ ] = array(
93 93
             'memory' => memory_get_peak_usage(),
94 94
             'name' => $name,
95 95
             'time' => $microtime,
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
      * @param array $timer
102 102
      * @return array
103 103
      */
104
-    protected function normalize($timer)
104
+    protected function normalize( $timer )
105 105
     {
106
-        return wp_parse_args((array) $timer, array(
106
+        return wp_parse_args( (array) $timer, array(
107 107
             'memory' => 0,
108 108
             'name' => '',
109 109
             'time' => 0,
110
-        ));
110
+        ) );
111 111
     }
112 112
 }
Please login to merge, or discard this patch.
src/Controller.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
      */
10 10
     protected $app;
11 11
 
12
-    public function __construct(Application $app)
12
+    public function __construct( Application $app )
13 13
     {
14 14
         $this->app = $app;
15 15
     }
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function enqueueAssets()
23 23
     {
24
-        wp_enqueue_script(Application::ID, $this->app->url('assets/main.js'));
25
-        wp_enqueue_style(Application::ID, $this->app->url('assets/main.css'), array('dashicons'));
26
-        wp_enqueue_style(Application::ID.'-syntax', $this->app->url('assets/syntax.css'));
24
+        wp_enqueue_script( Application::ID, $this->app->url( 'assets/main.js' ) );
25
+        wp_enqueue_style( Application::ID, $this->app->url( 'assets/main.css' ), array( 'dashicons' ) );
26
+        wp_enqueue_style( Application::ID . '-syntax', $this->app->url( 'assets/syntax.css' ) );
27 27
     }
28 28
 
29 29
     /**
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
      * @return string
32 32
      * @action admin_body_class
33 33
      */
34
-    public function filterBodyClasses($classes)
34
+    public function filterBodyClasses( $classes )
35 35
     {
36
-        return trim($classes.' '.Application::ID);
36
+        return trim( $classes . ' ' . Application::ID );
37 37
     }
38 38
 
39 39
     /**
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function initConsole()
44 44
     {
45
-        if (Application::CONSOLE_HOOK != func_get_arg(0)) {
45
+        if( Application::CONSOLE_HOOK != func_get_arg( 0 ) ) {
46 46
             return;
47 47
         }
48
-        $args = array_pad(func_get_args(), 4, '');
49
-        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4);
50
-        $entry = array_pop($backtrace);
51
-        $location = $args[3];
52
-        if (empty(trim($location)) && array_key_exists('file', $entry)) {
53
-            $path = explode(ABSPATH, $entry['file']);
54
-            $location = sprintf('%s:%s', array_pop($path), $entry['line']);
48
+        $args = array_pad( func_get_args(), 4, '' );
49
+        $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 4 );
50
+        $entry = array_pop( $backtrace );
51
+        $location = $args[ 3 ];
52
+        if( empty( trim( $location ) ) && array_key_exists( 'file', $entry ) ) {
53
+            $path = explode( ABSPATH, $entry[ 'file' ] );
54
+            $location = sprintf( '%s:%s', array_pop( $path ), $entry[ 'line' ] );
55 55
         }
56
-        $this->app->console->store($args[1], $args[2], '['.$location.'] ');
56
+        $this->app->console->store( $args[ 1 ], $args[ 2 ], '[' . $location . '] ' );
57 57
     }
58 58
 
59 59
     /**
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function initProfiler()
64 64
     {
65
-        if (Application::PROFILER_HOOK != func_get_arg(0)) {
65
+        if( Application::PROFILER_HOOK != func_get_arg( 0 ) ) {
66 66
             return;
67 67
         }
68
-        $this->app->profiler->trace(func_get_arg(1));
68
+        $this->app->profiler->trace( func_get_arg( 1 ) );
69 69
     }
70 70
 
71 71
     /**
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function registerLanguages()
85 85
     {
86
-        load_plugin_textdomain(Application::ID, false,
87
-            plugin_basename($this->app->path()).Application::LANG
86
+        load_plugin_textdomain( Application::ID, false,
87
+            plugin_basename( $this->app->path() ) . Application::LANG
88 88
         );
89 89
     }
90 90
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function renderBar()
97 97
     {
98
-        apply_filters('debug', 'Profiler Stopped');
99
-        $this->app->render('debug-bar', array(
98
+        apply_filters( 'debug', 'Profiler Stopped' );
99
+        $this->app->render( 'debug-bar', array(
100 100
             'blackbar' => $this->app,
101 101
             'actions' => $this->app->actions,
102 102
             'actionsLabel' => $this->getSlowActionsLabel(),
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             'queries' => $this->getQueries(),
108 108
             'queriesLabel' => $this->getQueriesLabel(),
109 109
             'templates' => $this->getTemplates(),
110
-        ));
110
+        ) );
111 111
     }
112 112
 
113 113
     /**
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
      * @param int $decimals
116 116
      * @return string
117 117
      */
118
-    protected function convertToMiliseconds($time, $decimals = 2)
118
+    protected function convertToMiliseconds( $time, $decimals = 2 )
119 119
     {
120
-        return number_format($time * 1000, $decimals);
120
+        return number_format( $time * 1000, $decimals );
121 121
     }
122 122
 
123 123
     /**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     protected function getConsoleEntries()
127 127
     {
128
-        return array_merge($this->getErrors(), $this->app->console->entries);
128
+        return array_merge( $this->getErrors(), $this->app->console->entries );
129 129
     }
130 130
 
131 131
     /**
@@ -135,25 +135,25 @@  discard block
 block discarded – undo
135 135
     {
136 136
         $class = '';
137 137
         $entries = $this->getConsoleEntries();
138
-        $entryCount = count($entries);
138
+        $entryCount = count( $entries );
139 139
         $errorCount = 0;
140
-        $label = __('Console', 'blackbar');
141
-        foreach ($entries as $entry) {
142
-            if (in_array($entry['errno'], [E_NOTICE, E_STRICT, E_DEPRECATED])) {
140
+        $label = __( 'Console', 'blackbar' );
141
+        foreach( $entries as $entry ) {
142
+            if( in_array( $entry[ 'errno' ], [ E_NOTICE, E_STRICT, E_DEPRECATED ] ) ) {
143 143
                 $class = 'glbb-warning';
144 144
             }
145
-            if (in_array($entry['errno'], [E_WARNING])) {
145
+            if( in_array( $entry[ 'errno' ], [ E_WARNING ] ) ) {
146 146
                 ++$errorCount;
147 147
             }
148 148
         }
149
-        if ($entryCount > 0) {
150
-            $label .= sprintf(' (%d)', $entryCount);
149
+        if( $entryCount > 0 ) {
150
+            $label .= sprintf( ' (%d)', $entryCount );
151 151
         }
152
-        if ($errorCount > 0) {
152
+        if( $errorCount > 0 ) {
153 153
             $class = 'glbb-error';
154
-            $label .= sprintf(' (%d, %d!)', $entryCount, $errorCount);
154
+            $label .= sprintf( ' (%d, %d!)', $entryCount, $errorCount );
155 155
         }
156
-        return '<span class="'.$class.'">'.$label.'</span>';
156
+        return '<span class="' . $class . '">' . $label . '</span>';
157 157
     }
158 158
 
159 159
     /**
@@ -162,24 +162,24 @@  discard block
 block discarded – undo
162 162
     protected function getErrors()
163 163
     {
164 164
         $errors = array();
165
-        foreach ($this->app->errors as $error) {
165
+        foreach( $this->app->errors as $error ) {
166 166
             $class = 'glbb-info';
167
-            if (in_array($error['errno'], [E_NOTICE, E_STRICT, E_DEPRECATED])) {
167
+            if( in_array( $error[ 'errno' ], [ E_NOTICE, E_STRICT, E_DEPRECATED ] ) ) {
168 168
                 $class = 'glbb-warning';
169 169
             }
170
-            if (E_WARNING == $error['errno']) {
170
+            if( E_WARNING == $error[ 'errno' ] ) {
171 171
                 $class = 'glbb-error';
172 172
             }
173
-            if ($error['count'] > 1) {
174
-                $error['name'] .= ' ('.$error['count'].')';
173
+            if( $error[ 'count' ] > 1 ) {
174
+                $error[ 'name' ] .= ' (' . $error[ 'count' ] . ')';
175 175
             }
176
-            $errors[] = array(
177
-                'errno' => $error['errno'],
178
-                'name' => '<span class="'.$class.'">'.$error['name'].'</span>',
179
-                'message' => sprintf(__('%s on line %s in file %s', 'blackbar'),
180
-                    $error['message'],
181
-                    $error['line'],
182
-                    $error['file']
176
+            $errors[ ] = array(
177
+                'errno' => $error[ 'errno' ],
178
+                'name' => '<span class="' . $class . '">' . $error[ 'name' ] . '</span>',
179
+                'message' => sprintf( __( '%s on line %s in file %s', 'blackbar' ),
180
+                    $error[ 'message' ],
181
+                    $error[ 'line' ],
182
+                    $error[ 'file' ]
183 183
                 ),
184 184
             );
185 185
         }
@@ -191,15 +191,15 @@  discard block
 block discarded – undo
191 191
      */
192 192
     protected function getIncludedFiles()
193 193
     {
194
-        $files = array_values(array_filter(get_included_files(), function ($file) {
195
-            $bool = false !== strpos($file, '/themes/')
196
-                && false === strpos($file, '/functions.php');
197
-            return (bool) apply_filters('blackbar/templates/file', $bool, $file);
198
-        }));
199
-        return array_map(function ($key, $value) {
200
-            $value = str_replace(trailingslashit(WP_CONTENT_DIR), '', $value);
201
-            return sprintf('[%s] => %s', $key, $value);
202
-        }, array_keys($files), $files);
194
+        $files = array_values( array_filter( get_included_files(), function( $file ) {
195
+            $bool = false !== strpos( $file, '/themes/' )
196
+                && false === strpos( $file, '/functions.php' );
197
+            return (bool) apply_filters( 'blackbar/templates/file', $bool, $file );
198
+        }) );
199
+        return array_map( function( $key, $value ) {
200
+            $value = str_replace( trailingslashit( WP_CONTENT_DIR ), '', $value );
201
+            return sprintf( '[%s] => %s', $key, $value );
202
+        }, array_keys( $files ), $files );
203 203
     }
204 204
 
205 205
     /**
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
      */
208 208
     protected function getProfilerLabel()
209 209
     {
210
-        $label = __('Profiler', 'blackbar');
211
-        $profilerTime = $this->convertToMiliseconds($this->app->profiler->getTotalTime(), 0);
212
-        if ($profilerTime > 0) {
213
-            $label .= sprintf(' (%s %s)', $profilerTime, __('ms', 'blackbar'));
210
+        $label = __( 'Profiler', 'blackbar' );
211
+        $profilerTime = $this->convertToMiliseconds( $this->app->profiler->getTotalTime(), 0 );
212
+        if( $profilerTime > 0 ) {
213
+            $label .= sprintf( ' (%s %s)', $profilerTime, __( 'ms', 'blackbar' ) );
214 214
         }
215 215
         return $label;
216 216
     }
@@ -226,15 +226,15 @@  discard block
 block discarded – undo
226 226
             'AND', 'FROM', 'GROUP BY', 'INNER JOIN', 'LIMIT', 'ON DUPLICATE KEY UPDATE',
227 227
             'ORDER BY', 'SET', 'WHERE',
228 228
         );
229
-        $replace = array_map(function ($value) {
230
-            return PHP_EOL.$value;
231
-        }, $search);
232
-        foreach ($wpdb->queries as $query) {
233
-            $miliseconds = number_format(round($query[1] * 1000, 4), 4);
234
-            $sql = preg_replace('/\s\s+/', ' ', trim($query[0]));
235
-            $sql = str_replace(PHP_EOL, ' ', $sql);
236
-            $sql = str_replace($search, $replace, $sql);
237
-            $queries[] = array(
229
+        $replace = array_map( function( $value ) {
230
+            return PHP_EOL . $value;
231
+        }, $search );
232
+        foreach( $wpdb->queries as $query ) {
233
+            $miliseconds = number_format( round( $query[ 1 ] * 1000, 4 ), 4 );
234
+            $sql = preg_replace( '/\s\s+/', ' ', trim( $query[ 0 ] ) );
235
+            $sql = str_replace( PHP_EOL, ' ', $sql );
236
+            $sql = str_replace( $search, $replace, $sql );
237
+            $queries[ ] = array(
238 238
                 'ms' => $miliseconds,
239 239
                 'sql' => $sql,
240 240
             );
@@ -247,18 +247,18 @@  discard block
 block discarded – undo
247 247
      */
248 248
     protected function getQueriesLabel()
249 249
     {
250
-        $label = __('SQL', 'blackbar');
251
-        if (!SAVEQUERIES) {
250
+        $label = __( 'SQL', 'blackbar' );
251
+        if( !SAVEQUERIES ) {
252 252
             return $label;
253 253
         }
254 254
         global $wpdb;
255 255
         $queryTime = 0;
256
-        foreach ($wpdb->queries as $query) {
257
-            $queryTime += $query[1];
256
+        foreach( $wpdb->queries as $query ) {
257
+            $queryTime += $query[ 1 ];
258 258
         }
259
-        $queriesCount = '<span class="glbb-queries-count">'.count($wpdb->queries).'</span>';
260
-        $queriesTime = '<span class="glbb-queries-time">'.$this->convertToMiliseconds($queryTime).'</span>';
261
-        return $label.sprintf(' (%s %s | %s %s)', $queriesCount, __('queries', 'blackbar'), $queriesTime, __('ms', 'blackbar'));
259
+        $queriesCount = '<span class="glbb-queries-count">' . count( $wpdb->queries ) . '</span>';
260
+        $queriesTime = '<span class="glbb-queries-time">' . $this->convertToMiliseconds( $queryTime ) . '</span>';
261
+        return $label . sprintf( ' (%s %s | %s %s)', $queriesCount, __( 'queries', 'blackbar' ), $queriesTime, __( 'ms', 'blackbar' ) );
262 262
     }
263 263
 
264 264
     /**
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
      */
267 267
     protected function getSlowActionsLabel()
268 268
     {
269
-        $label = __('Hooks', 'blackbar');
270
-        $totalTime = $this->convertToMiliseconds($this->app->actions->getTotalTime(), 0);
271
-        if ($totalTime > 0) {
272
-            $label .= sprintf(' (%s %s)', $totalTime, __('ms', 'blackbar'));
269
+        $label = __( 'Hooks', 'blackbar' );
270
+        $totalTime = $this->convertToMiliseconds( $this->app->actions->getTotalTime(), 0 );
271
+        if( $totalTime > 0 ) {
272
+            $label .= sprintf( ' (%s %s)', $totalTime, __( 'ms', 'blackbar' ) );
273 273
         }
274 274
         return $label;
275 275
     }
@@ -279,14 +279,14 @@  discard block
 block discarded – undo
279 279
      */
280 280
     protected function getTemplates()
281 281
     {
282
-        if (is_admin()) {
282
+        if( is_admin() ) {
283 283
             return;
284 284
         }
285
-        if (class_exists('\GeminiLabs\Castor\Facades\Development')) {
285
+        if( class_exists( '\GeminiLabs\Castor\Facades\Development' ) ) {
286 286
             ob_start();
287 287
             \GeminiLabs\Castor\Facades\Development::printTemplatePaths();
288 288
             return ob_get_clean();
289 289
         }
290
-        return '<pre>'.implode(PHP_EOL, $this->getIncludedFiles()).'</pre>';
290
+        return '<pre>' . implode( PHP_EOL, $this->getIncludedFiles() ) . '</pre>';
291 291
     }
292 292
 }
Please login to merge, or discard this patch.
src/SlowActions.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -37,18 +37,18 @@  discard block
 block discarded – undo
37 37
 
38 38
     public function __construct()
39 39
     {
40
-        $this->flow = [];
41
-        $this->start = microtime(true);
40
+        $this->flow = [ ];
41
+        $this->start = microtime( true );
42 42
     }
43 43
 
44 44
     /**
45 45
      * @return array
46 46
      */
47
-    public function getTotalTimeForHook(array $data)
47
+    public function getTotalTimeForHook( array $data )
48 48
     {
49 49
         $total = 0;
50
-        foreach ($data['time'] as $time) {
51
-            $total += ($time['stop'] - $time['start']) * 1000;
50
+        foreach( $data[ 'time' ] as $time ) {
51
+            $total += ( $time[ 'stop' ] - $time[ 'start' ] ) * 1000;
52 52
         }
53 53
         return $total;
54 54
     }
@@ -56,30 +56,30 @@  discard block
 block discarded – undo
56 56
     /**
57 57
      * @return array
58 58
      */
59
-    public function addCallbacksForAction($action)
59
+    public function addCallbacksForAction( $action )
60 60
     {
61 61
         global $wp_filter;
62
-        if (!array_key_exists($action, $this->flow)) {
62
+        if( !array_key_exists( $action, $this->flow ) ) {
63 63
             return;
64 64
         }
65
-        $this->flow[$action]['callbacks_count'] = 0;
66
-        foreach ($wp_filter[$action] as $priority => $callbacks) {
67
-            if (!array_key_exists($priority, $this->flow[$action]['callbacks'])) {
68
-                $this->flow[$action]['callbacks'][$priority] = [];
65
+        $this->flow[ $action ][ 'callbacks_count' ] = 0;
66
+        foreach( $wp_filter[ $action ] as $priority => $callbacks ) {
67
+            if( !array_key_exists( $priority, $this->flow[ $action ][ 'callbacks' ] ) ) {
68
+                $this->flow[ $action ][ 'callbacks' ][ $priority ] = [ ];
69 69
             }
70
-            foreach ($callbacks as $callback) {
71
-                if (is_array($callback['function']) && 2 == count($callback['function'])) {
72
-                    list($object, $method) = $callback['function'];
73
-                    if (is_object($object)) {
74
-                        $object = get_class($object);
70
+            foreach( $callbacks as $callback ) {
71
+                if( is_array( $callback[ 'function' ] ) && 2 == count( $callback[ 'function' ] ) ) {
72
+                    list( $object, $method ) = $callback[ 'function' ];
73
+                    if( is_object( $object ) ) {
74
+                        $object = get_class( $object );
75 75
                     }
76
-                    $this->flow[$action]['callbacks'][$priority][] = sprintf('%s::%s', $object, $method);
77
-                } elseif (is_object($callback['function'])) {
78
-                    $this->flow[$action]['callbacks'][$priority][] = get_class($callback['function']);
76
+                    $this->flow[ $action ][ 'callbacks' ][ $priority ][ ] = sprintf( '%s::%s', $object, $method );
77
+                } elseif( is_object( $callback[ 'function' ] ) ) {
78
+                    $this->flow[ $action ][ 'callbacks' ][ $priority ][ ] = get_class( $callback[ 'function' ] );
79 79
                 } else {
80
-                    $this->flow[$action]['callbacks'][$priority][] = $callback['function'];
80
+                    $this->flow[ $action ][ 'callbacks' ][ $priority ][ ] = $callback[ 'function' ];
81 81
                 }
82
-                ++$this->flow[$action]['callbacks_count'];
82
+                ++$this->flow[ $action ][ 'callbacks_count' ];
83 83
             }
84 84
         }
85 85
     }
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function getMeasure()
91 91
     {
92
-        foreach ($this->flow as $action => $data) {
93
-            $total = $this->getTotalTimeForHook($data);
94
-            $this->flow[$action]['total'] = $total;
92
+        foreach( $this->flow as $action => $data ) {
93
+            $total = $this->getTotalTimeForHook( $data );
94
+            $this->flow[ $action ][ 'total' ] = $total;
95 95
             $this->totalTime += $total;
96
-            $this->totalActions += $data['count'];
97
-            $this->addCallbacksForAction($action);
96
+            $this->totalActions += $data[ 'count' ];
97
+            $this->addCallbacksForAction( $action );
98 98
         }
99
-        uasort($this->flow, [$this, 'sortByTime']);
99
+        uasort( $this->flow, [ $this, 'sortByTime' ] );
100 100
         return $this->flow;
101 101
     }
102 102
 
@@ -124,28 +124,28 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function startTimer()
126 126
     {
127
-        if (!isset($this->flow[current_filter()])) {
128
-            $this->flow[current_filter()] = [
129
-                'callbacks' => [],
127
+        if( !isset( $this->flow[ current_filter() ] ) ) {
128
+            $this->flow[ current_filter() ] = [
129
+                'callbacks' => [ ],
130 130
                 'count' => 0,
131
-                'stack' => [],
132
-                'time' => [],
131
+                'stack' => [ ],
132
+                'time' => [ ],
133 133
             ];
134
-            add_action(current_filter(), [$this, 'stopTimer'], 9000);
134
+            add_action( current_filter(), [ $this, 'stopTimer' ], 9000 );
135 135
         }
136
-        $count = ++$this->flow[current_filter()]['count'];
137
-        array_push($this->flow[current_filter()]['stack'], ['start' => microtime(true)]);
136
+        $count = ++$this->flow[ current_filter() ][ 'count' ];
137
+        array_push( $this->flow[ current_filter() ][ 'stack' ], [ 'start' => microtime( true ) ] );
138 138
     }
139 139
 
140 140
     /**
141 141
      * @param mixed $possibleFilter
142 142
      * @return mixed
143 143
      */
144
-    public function stopTimer($possibleFilter = null)
144
+    public function stopTimer( $possibleFilter = null )
145 145
     {
146
-        $time = array_pop($this->flow[current_filter()]['stack']);
147
-        $time['stop'] = microtime(true);
148
-        array_push($this->flow[current_filter()]['time'], $time);
146
+        $time = array_pop( $this->flow[ current_filter() ][ 'stack' ] );
147
+        $time[ 'stop' ] = microtime( true );
148
+        array_push( $this->flow[ current_filter() ][ 'time' ], $time );
149 149
         return $possibleFilter;
150 150
     }
151 151
 
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
      * @param array $b
155 155
      * @return int
156 156
      */
157
-    protected function sortByTime($a, $b)
157
+    protected function sortByTime( $a, $b )
158 158
     {
159
-        if ($a['total'] == $b['total']) {
159
+        if( $a[ 'total' ] == $b[ 'total' ] ) {
160 160
             return 0;
161 161
         }
162
-        return ($a['total'] > $b['total']) ? -1 : 1;
162
+        return ( $a[ 'total' ] > $b[ 'total' ] ) ? -1 : 1;
163 163
     }
164 164
 }
Please login to merge, or discard this patch.
src/Console.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,19 +31,19 @@  discard block
 block discarded – undo
31 31
      * @param string $message
32 32
      * @return static
33 33
      */
34
-    public function store($message, $errno = 0, $location = '')
34
+    public function store( $message, $errno = 0, $location = '' )
35 35
     {
36 36
         $errname = 'Debug';
37
-        if (array_key_exists($errno, static::MAPPED_ERROR_CODES)) {
38
-            $errname = ucfirst($errno);
39
-            $errno = static::MAPPED_ERROR_CODES[$errno];
40
-        } elseif (array_key_exists($errno, static::ERROR_CODES)) {
41
-            $errname = static::ERROR_CODES[$errno];
37
+        if( array_key_exists( $errno, static::MAPPED_ERROR_CODES ) ) {
38
+            $errname = ucfirst( $errno );
39
+            $errno = static::MAPPED_ERROR_CODES[ $errno ];
40
+        } elseif( array_key_exists( $errno, static::ERROR_CODES ) ) {
41
+            $errname = static::ERROR_CODES[ $errno ];
42 42
         }
43
-        $this->entries[] = array(
43
+        $this->entries[ ] = array(
44 44
             'errno' => $errno,
45
-            'message' => $location.$this->normalizeValue($message),
46
-            'name' => sprintf('<span class="glbb-info glbb-%s">%s</span>', strtolower($errname), $errname),
45
+            'message' => $location . $this->normalizeValue( $message ),
46
+            'name' => sprintf( '<span class="glbb-info glbb-%s">%s</span>', strtolower( $errname ), $errname ),
47 47
         );
48 48
         return $this;
49 49
     }
@@ -52,24 +52,24 @@  discard block
 block discarded – undo
52 52
      * @param mixed $value
53 53
      * @return bool
54 54
      */
55
-    protected function isObjectOrArray($value)
55
+    protected function isObjectOrArray( $value )
56 56
     {
57
-        return is_object($value) || is_array($value);
57
+        return is_object( $value ) || is_array( $value );
58 58
     }
59 59
 
60 60
     /**
61 61
      * @param mixed $value
62 62
      * @return string
63 63
      */
64
-    protected function normalizeValue($value)
64
+    protected function normalizeValue( $value )
65 65
     {
66
-        if ($value instanceof DateTime) {
67
-            $value = $value->format('Y-m-d H:i:s');
68
-        } elseif ($this->isObjectOrArray($value)) {
69
-            $value = print_r(json_decode(json_encode($value)), true);
70
-        } elseif (is_resource($value)) {
66
+        if( $value instanceof DateTime ) {
67
+            $value = $value->format( 'Y-m-d H:i:s' );
68
+        } elseif( $this->isObjectOrArray( $value ) ) {
69
+            $value = print_r( json_decode( json_encode( $value ) ), true );
70
+        } elseif( is_resource( $value ) ) {
71 71
             $value = (string) $value;
72 72
         }
73
-        return esc_html($value);
73
+        return esc_html( $value );
74 74
     }
75 75
 }
Please login to merge, or discard this patch.
blackbar.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,18 +15,18 @@
 block discarded – undo
15 15
  * Text Domain: blackbar
16 16
  * Domain Path: languages
17 17
  */
18
-defined('WPINC') || die;
18
+defined( 'WPINC' ) || die;
19 19
 
20
-if (!class_exists('GL_Plugin_Check_v3')) {
21
-    require_once __DIR__.'/activate.php';
20
+if( !class_exists( 'GL_Plugin_Check_v3' ) ) {
21
+    require_once __DIR__ . '/activate.php';
22 22
 }
23
-if (!(new GL_Plugin_Check_v3(__FILE__, array('php' => '5.6', 'wordpress' => '5.2.0')))->canProceed()) {
23
+if( !( new GL_Plugin_Check_v3( __FILE__, array( 'php' => '5.6', 'wordpress' => '5.2.0' ) ) )->canProceed() ) {
24 24
     return;
25 25
 }
26
-require_once __DIR__.'/autoload.php';
27
-require_once __DIR__.'/compatibility.php';
26
+require_once __DIR__ . '/autoload.php';
27
+require_once __DIR__ . '/compatibility.php';
28 28
 
29
-if (!defined('SAVEQUERIES')) {
30
-    define('SAVEQUERIES', 1);
29
+if( !defined( 'SAVEQUERIES' ) ) {
30
+    define( 'SAVEQUERIES', 1 );
31 31
 }
32
-(new GeminiLabs\BlackBar\Application())->init();
32
+( new GeminiLabs\BlackBar\Application() )->init();
Please login to merge, or discard this patch.
activate.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-defined('WPINC') || die;
3
+defined( 'WPINC' ) || die;
4 4
 
5 5
 /**
6 6
  * Check for minimum system requirments on plugin activation.
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
     /**
25 25
      * @param string $file
26 26
      */
27
-    public function __construct($file, array $versions = array())
27
+    public function __construct( $file, array $versions = array() )
28 28
     {
29
-        $this->file = realpath($file);
30
-        $this->versions = wp_parse_args($versions, array(
29
+        $this->file = realpath( $file );
30
+        $this->versions = wp_parse_args( $versions, array(
31 31
             'php' => static::MIN_PHP_VERSION,
32 32
             'wordpress' => static::MIN_WORDPRESS_VERSION,
33
-        ));
33
+        ) );
34 34
     }
35 35
 
36 36
     /**
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function canProceed()
40 40
     {
41
-        if ($this->isValid()) {
41
+        if( $this->isValid() ) {
42 42
             return true;
43 43
         }
44
-        add_action('activated_plugin', array($this, 'deactivate'));
45
-        add_action('admin_notices', array($this, 'deactivate'));
44
+        add_action( 'activated_plugin', array( $this, 'deactivate' ) );
45
+        add_action( 'admin_notices', array( $this, 'deactivate' ) );
46 46
         return false;
47 47
     }
48 48
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function isPhpValid()
53 53
     {
54
-        return !version_compare(PHP_VERSION, $this->versions['php'], '<');
54
+        return !version_compare( PHP_VERSION, $this->versions[ 'php' ], '<' );
55 55
     }
56 56
 
57 57
     /**
@@ -68,25 +68,25 @@  discard block
 block discarded – undo
68 68
     public function isWpValid()
69 69
     {
70 70
         global $wp_version;
71
-        return !version_compare($wp_version, $this->versions['wordpress'], '<');
71
+        return !version_compare( $wp_version, $this->versions[ 'wordpress' ], '<' );
72 72
     }
73 73
 
74 74
     /**
75 75
      * @param string $plugin
76 76
      * @return void
77 77
      */
78
-    public function deactivate($plugin)
78
+    public function deactivate( $plugin )
79 79
     {
80
-        if ($this->isValid()) {
80
+        if( $this->isValid() ) {
81 81
             return;
82 82
         }
83
-        $pluginSlug = plugin_basename($this->file);
84
-        if ($plugin == $pluginSlug) {
83
+        $pluginSlug = plugin_basename( $this->file );
84
+        if( $plugin == $pluginSlug ) {
85 85
             $this->redirect(); //exit
86 86
         }
87
-        $pluginData = get_file_data($this->file, array('name' => 'Plugin Name'), 'plugin');
88
-        deactivate_plugins($pluginSlug);
89
-        $this->printNotice($pluginData['name']);
87
+        $pluginData = get_file_data( $this->file, array( 'name' => 'Plugin Name' ), 'plugin' );
88
+        deactivate_plugins( $pluginSlug );
89
+        $this->printNotice( $pluginData[ 'name' ] );
90 90
     }
91 91
 
92 92
     /**
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
     protected function getMessages()
96 96
     {
97 97
         return array(
98
-            __('The %s plugin was deactivated.', 'blackbar'),
99
-            __('This plugin requires %s or greater in order to work properly.', 'blackbar'),
100
-            __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'blackbar'),
101
-            __('PHP version', 'blackbar'),
102
-            __('WordPress version', 'blackbar'),
103
-            __('Update WordPress', 'blackbar'),
104
-            __('You can use the %s plugin to restore %s to the previous version.', 'blackbar'),
98
+            __( 'The %s plugin was deactivated.', 'blackbar' ),
99
+            __( 'This plugin requires %s or greater in order to work properly.', 'blackbar' ),
100
+            __( 'Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'blackbar' ),
101
+            __( 'PHP version', 'blackbar' ),
102
+            __( 'WordPress version', 'blackbar' ),
103
+            __( 'Update WordPress', 'blackbar' ),
104
+            __( 'You can use the %s plugin to restore %s to the previous version.', 'blackbar' ),
105 105
         );
106 106
     }
107 107
 
@@ -109,22 +109,22 @@  discard block
 block discarded – undo
109 109
      * @param string $pluginName
110 110
      * @return void
111 111
      */
112
-    protected function printNotice($pluginName)
112
+    protected function printNotice( $pluginName )
113 113
     {
114 114
         $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>';
115 115
         $messages = $this->getMessages();
116
-        $rollbackMessage = sprintf('<strong>'.$messages[6].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName);
117
-        if (!$this->isPhpValid()) {
118
-            printf($noticeTemplate,
119
-                sprintf($messages[0], $pluginName),
120
-                sprintf($messages[1], $messages[3].' '.$this->versions['php']),
121
-                sprintf($messages[2], PHP_VERSION).'</p><p>'.$rollbackMessage
116
+        $rollbackMessage = sprintf( '<strong>' . $messages[ 6 ] . '</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName );
117
+        if( !$this->isPhpValid() ) {
118
+            printf( $noticeTemplate,
119
+                sprintf( $messages[ 0 ], $pluginName ),
120
+                sprintf( $messages[ 1 ], $messages[ 3 ] . ' ' . $this->versions[ 'php' ] ),
121
+                sprintf( $messages[ 2 ], PHP_VERSION ) . '</p><p>' . $rollbackMessage
122 122
             );
123
-        } elseif (!$this->isWpValid()) {
124
-            printf($noticeTemplate,
125
-                sprintf($messages[0], $pluginName),
126
-                sprintf($messages[1], $messages[4].' '.$this->versions['wordpress']),
127
-                $rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages[5])
123
+        } elseif( !$this->isWpValid() ) {
124
+            printf( $noticeTemplate,
125
+                sprintf( $messages[ 0 ], $pluginName ),
126
+                sprintf( $messages[ 1 ], $messages[ 4 ] . ' ' . $this->versions[ 'wordpress' ] ),
127
+                $rollbackMessage . '</p><p>' . sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[ 5 ] )
128 128
             );
129 129
         }
130 130
     }
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
      */
135 135
     protected function redirect()
136 136
     {
137
-        wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s',
138
-            filter_input(INPUT_GET, 'plugin_status'),
139
-            filter_input(INPUT_GET, 'paged'),
140
-            filter_input(INPUT_GET, 's')
141
-        )));
137
+        wp_safe_redirect( self_admin_url( sprintf( 'plugins.php?plugin_status=%s&paged=%s&s=%s',
138
+            filter_input( INPUT_GET, 'plugin_status' ),
139
+            filter_input( INPUT_GET, 'paged' ),
140
+            filter_input( INPUT_GET, 's' )
141
+        ) ) );
142 142
         exit;
143 143
     }
144 144
 }
Please login to merge, or discard this patch.