Passed
Push — master ( 67e49f...cae36e )
by Paul
02:43
created
plugin/Modules/Profiler.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
     /**
31 31
      * @var array
32 32
      */
33
-    protected $timer = [];
33
+    protected $timer = [ ];
34 34
 
35 35
     public function entries(): array
36 36
     {
37
-        $entries = [];
38
-        foreach ($this->entries as $entry) {
39
-            $entry['time'] = $this->formatTime($entry['time']);
40
-            $entries[] = $entry;
37
+        $entries = [ ];
38
+        foreach( $this->entries as $entry ) {
39
+            $entry[ 'time' ] = $this->formatTime( $entry[ 'time' ] );
40
+            $entries[ ] = $entry;
41 41
         }
42 42
         return $entries;
43 43
     }
@@ -49,28 +49,28 @@  discard block
 block discarded – undo
49 49
 
50 50
     public function label(): string
51 51
     {
52
-        return __('Profiler', 'blackbar');
52
+        return __( 'Profiler', 'blackbar' );
53 53
     }
54 54
 
55
-    public function set(string $property): void
55
+    public function set( string $property ): void
56 56
     {
57
-        if ('noise' === $property) {
58
-            $this->noise = (int) hrtime(true) - $this->start;
59
-        } elseif ('start' === $property) {
60
-            $this->start = (int) hrtime(true);
57
+        if( 'noise' === $property ) {
58
+            $this->noise = (int) hrtime( true ) - $this->start;
59
+        } elseif( 'start' === $property ) {
60
+            $this->start = (int) hrtime( true );
61 61
             $this->memory_start = memory_get_peak_usage();
62
-        } elseif ('stop' === $property) {
63
-            $this->stop = (int) hrtime(true);
62
+        } elseif( 'stop' === $property ) {
63
+            $this->stop = (int) hrtime( true );
64 64
             $this->memory_stop = memory_get_peak_usage();
65 65
         }
66 66
     }
67 67
 
68
-    public function start(string $name): void
68
+    public function start( string $name ): void
69 69
     {
70 70
         $this->timer = [
71 71
             'memory' => memory_get_peak_usage(),
72 72
             'name' => $name,
73
-            'start' => (int) hrtime(true),
73
+            'start' => (int) hrtime( true ),
74 74
             'stop' => 0,
75 75
             'time' => 0,
76 76
         ];
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 
79 79
     public function stop(): void
80 80
     {
81
-        if (!empty($this->timer)) {
82
-            $nanoseconds = (int) hrtime(true);
83
-            $this->timer['memory'] = max(0, memory_get_peak_usage() - $this->timer['memory']);
84
-            $this->timer['stop'] = $nanoseconds;
85
-            $this->timer['time'] = max(0, $nanoseconds - $this->timer['start'] - $this->noise);
86
-            $this->entries[] = $this->timer;
87
-            $this->timer = []; // reset timer
81
+        if( !empty( $this->timer ) ) {
82
+            $nanoseconds = (int) hrtime( true );
83
+            $this->timer[ 'memory' ] = max( 0, memory_get_peak_usage() - $this->timer[ 'memory' ] );
84
+            $this->timer[ 'stop' ] = $nanoseconds;
85
+            $this->timer[ 'time' ] = max( 0, $nanoseconds - $this->timer[ 'start' ] - $this->noise );
86
+            $this->entries[ ] = $this->timer;
87
+            $this->timer = [ ]; // reset timer
88 88
         }
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
plugin/Controller.php 1 patch
Spacing   +29 added lines, -29 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
     }
@@ -20,18 +20,18 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function enqueueAssets(): void
22 22
     {
23
-        wp_enqueue_script(Application::ID, $this->app->url('assets/main.js'));
24
-        wp_enqueue_style(Application::ID, $this->app->url('assets/main.css'), ['dashicons']);
25
-        wp_enqueue_style(Application::ID.'-syntax', $this->app->url('assets/syntax.css'));
23
+        wp_enqueue_script( Application::ID, $this->app->url( 'assets/main.js' ) );
24
+        wp_enqueue_style( Application::ID, $this->app->url( 'assets/main.css' ), [ 'dashicons' ] );
25
+        wp_enqueue_style( Application::ID . '-syntax', $this->app->url( 'assets/syntax.css' ) );
26 26
     }
27 27
 
28 28
     /**
29 29
      * @param string $classes
30 30
      * @action admin_body_class
31 31
      */
32
-    public function filterBodyClasses($classes): string
32
+    public function filterBodyClasses( $classes ): string
33 33
     {
34
-        return trim((string) $classes.' '.Application::ID);
34
+        return trim( (string) $classes . ' ' . Application::ID );
35 35
     }
36 36
 
37 37
     /**
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function initConsole(): void
41 41
     {
42
-        if (Application::CONSOLE_HOOK !== func_get_arg(0)) {
42
+        if( Application::CONSOLE_HOOK !== func_get_arg( 0 ) ) {
43 43
             return;
44 44
         }
45
-        $args = array_pad(func_get_args(), 4, '');
46
-        $args = array_combine(['hook', 'message', 'errno', 'location'], $args);
47
-        $args = array_map('sanitize_textarea_field', $args);
48
-        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4);
49
-        $entry = array_pop($backtrace); // get the fourth backtrace entry
50
-        if (empty(trim($args['location'])) && array_key_exists('file', $entry)) {
51
-            $path = explode(ABSPATH, $entry['file']);
52
-            $args['location'] = sprintf('%s:%s', array_pop($path), $entry['line']);
45
+        $args = array_pad( func_get_args(), 4, '' );
46
+        $args = array_combine( [ 'hook', 'message', 'errno', 'location' ], $args );
47
+        $args = array_map( 'sanitize_textarea_field', $args );
48
+        $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 4 );
49
+        $entry = array_pop( $backtrace ); // get the fourth backtrace entry
50
+        if( empty( trim( $args[ 'location' ] ) ) && array_key_exists( 'file', $entry ) ) {
51
+            $path = explode( ABSPATH, $entry[ 'file' ] );
52
+            $args[ 'location' ] = sprintf( '%s:%s', array_pop( $path ), $entry[ 'line' ] );
53 53
         }
54
-        $this->app->console->store($args['message'], $args['errno'], $args['location']);
54
+        $this->app->console->store( $args[ 'message' ], $args[ 'errno' ], $args[ 'location' ] );
55 55
     }
56 56
 
57 57
     /**
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function initProfiler(): void
69 69
     {
70
-        $hook = func_get_arg(0);
71
-        if (str_starts_with($hook, 'blackbar/profiler/')) {
72
-            $property = str_replace('blackbar/profiler/', '', $hook);
73
-            $this->app->profiler->set($property);
74
-        } elseif ('timer:start' === $hook) {
75
-            $name = func_num_args() > 1 ? func_get_arg(1) : 'Timer';
76
-            $this->app->profiler->start($name);
77
-        } elseif ('timer:stop' === $hook) {
70
+        $hook = func_get_arg( 0 );
71
+        if( str_starts_with( $hook, 'blackbar/profiler/' ) ) {
72
+            $property = str_replace( 'blackbar/profiler/', '', $hook );
73
+            $this->app->profiler->set( $property );
74
+        } elseif( 'timer:start' === $hook ) {
75
+            $name = func_num_args() > 1 ? func_get_arg( 1 ) : 'Timer';
76
+            $this->app->profiler->start( $name );
77
+        } elseif( 'timer:stop' === $hook ) {
78 78
             $this->app->profiler->stop();
79 79
         }
80 80
     }
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function registerLanguages(): void
86 86
     {
87
-        load_plugin_textdomain(Application::ID, false,
88
-            plugin_basename($this->app->path()).'/languages/'
87
+        load_plugin_textdomain( Application::ID, false,
88
+            plugin_basename( $this->app->path() ) . '/languages/'
89 89
         );
90 90
     }
91 91
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function renderBar(): void
97 97
     {
98
-        do_action('blackbar/profiler/stop'); // stop profiler
99
-        $this->app->render('debug-bar', [
98
+        do_action( 'blackbar/profiler/stop' ); // stop profiler
99
+        $this->app->render( 'debug-bar', [
100 100
             'modules' => [ // order is intentional
101 101
                 $this->app->console,
102 102
                 $this->app->profiler,
@@ -105,6 +105,6 @@  discard block
 block discarded – undo
105 105
                 $this->app->templates,
106 106
                 $this->app->globals,
107 107
             ],
108
-        ]);
108
+        ] );
109 109
     }
110 110
 }
Please login to merge, or discard this patch.