Passed
Push — master ( ccb079...7906b4 )
by Paul
04:39
created
plugin/Modules/Style.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     public function __construct()
36 36
     {
37
-        $this->style = glsr(OptionManager::class)->get('settings.general.style', 'default');
37
+        $this->style = glsr( OptionManager::class )->get( 'settings.general.style', 'default' );
38 38
         $this->setConfig();
39 39
     }
40 40
 
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
      * @param string $view
43 43
      * @return string
44 44
      */
45
-    public function filterView($view)
45
+    public function filterView( $view )
46 46
     {
47
-        $styledViews = apply_filters('site-reviews/style/views', [
47
+        $styledViews = apply_filters( 'site-reviews/style/views', [
48 48
             'templates/form/field',
49 49
             'templates/form/response',
50 50
             'templates/form/submit-button',
51 51
             'templates/reviews-form',
52
-        ]);
53
-        if (!preg_match('('.implode('|', $styledViews).')', $view)) {
52
+        ] );
53
+        if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) {
54 54
             return $view;
55 55
         }
56
-        $views = $this->generatePossibleViews($view);
57
-        foreach ($views as $possibleView) {
58
-            if (!file_exists(glsr()->file($possibleView))) {
56
+        $views = $this->generatePossibleViews( $view );
57
+        foreach( $views as $possibleView ) {
58
+            if( !file_exists( glsr()->file( $possibleView ) ) ) {
59 59
                 continue;
60 60
             }
61
-            return Str::removePrefix('views/', $possibleView);
61
+            return Str::removePrefix( 'views/', $possibleView );
62 62
         }
63 63
         return $view;
64 64
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function get()
70 70
     {
71
-        return apply_filters('site-reviews/style', $this->style);
71
+        return apply_filters( 'site-reviews/style', $this->style );
72 72
     }
73 73
 
74 74
     /**
@@ -77,77 +77,77 @@  discard block
 block discarded – undo
77 77
     public function setConfig()
78 78
     {
79 79
         $config = shortcode_atts(
80
-            array_fill_keys(['fields', 'pagination', 'validation'], []),
81
-            glsr()->config('styles/'.$this->style)
80
+            array_fill_keys( ['fields', 'pagination', 'validation'], [] ),
81
+            glsr()->config( 'styles/'.$this->style )
82 82
         );
83
-        $this->fields = glsr(StyleFieldsDefaults::class)->restrict($config['fields']);
84
-        $this->pagination = glsr(PaginationDefaults::class)->restrict($config['pagination']);
85
-        $this->validation = glsr(StyleValidationDefaults::class)->restrict($config['validation']);
83
+        $this->fields = glsr( StyleFieldsDefaults::class )->restrict( $config['fields'] );
84
+        $this->pagination = glsr( PaginationDefaults::class )->restrict( $config['pagination'] );
85
+        $this->validation = glsr( StyleValidationDefaults::class )->restrict( $config['validation'] );
86 86
     }
87 87
 
88 88
     /**
89 89
      * @return void
90 90
      */
91
-    public function modifyField(Builder $instance)
91
+    public function modifyField( Builder $instance )
92 92
     {
93
-        if (!$this->isPublicInstance($instance) || empty(array_filter($this->fields))) {
93
+        if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) ) {
94 94
             return;
95 95
         }
96
-        call_user_func_array([$this, 'customize'], [$instance]);
96
+        call_user_func_array( [$this, 'customize'], [$instance] );
97 97
     }
98 98
 
99 99
     /**
100 100
      * @return array
101 101
      */
102
-    public function paginationArgs(array $args)
102
+    public function paginationArgs( array $args )
103 103
     {
104
-        return wp_parse_args($args, $this->pagination);
104
+        return wp_parse_args( $args, $this->pagination );
105 105
     }
106 106
 
107 107
     /**
108 108
      * @return void
109 109
      */
110
-    protected function customize(Builder $instance)
110
+    protected function customize( Builder $instance )
111 111
     {
112
-        if (!array_key_exists($instance->tag, $this->fields)) {
112
+        if( !array_key_exists( $instance->tag, $this->fields ) ) {
113 113
             return;
114 114
         }
115
-        $args = wp_parse_args($instance->args, array_fill_keys(['class', 'type'], ''));
115
+        $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) );
116 116
         $key = $instance->tag.'_'.$args['type'];
117
-        $classes = Arr::get($this->fields, $key, Arr::get($this->fields, $instance->tag));
118
-        $instance->args['class'] = trim($args['class'].' '.$classes);
119
-        do_action_ref_array('site-reviews/customize/'.$this->style, [$instance]);
117
+        $classes = Arr::get( $this->fields, $key, Arr::get( $this->fields, $instance->tag ) );
118
+        $instance->args['class'] = trim( $args['class'].' '.$classes );
119
+        do_action_ref_array( 'site-reviews/customize/'.$this->style, [$instance] );
120 120
     }
121 121
 
122 122
     /**
123 123
      * @param string $view
124 124
      * @return array
125 125
      */
126
-    protected function generatePossibleViews($view)
126
+    protected function generatePossibleViews( $view )
127 127
     {
128
-        $basename = basename($view);
129
-        $basepath = rtrim($view, $basename);
128
+        $basename = basename( $view );
129
+        $basepath = rtrim( $view, $basename );
130 130
         $customPath = 'views/partials/styles/'.$this->style.'/';
131
-        $parts = explode('_', $basename);
131
+        $parts = explode( '_', $basename );
132 132
         $views = [
133 133
             $customPath.$basename,
134 134
             $customPath.$parts[0],
135 135
             $view,
136 136
             $basepath.$parts[0],
137 137
         ];
138
-        return array_filter($views);
138
+        return array_filter( $views );
139 139
     }
140 140
 
141 141
     /**
142 142
      * @return bool
143 143
      */
144
-    protected function isPublicInstance(Builder $instance)
144
+    protected function isPublicInstance( Builder $instance )
145 145
     {
146
-        $args = wp_parse_args($instance->args, [
146
+        $args = wp_parse_args( $instance->args, [
147 147
             'is_public' => false,
148 148
             'is_raw' => false,
149
-        ]);
150
-        if (is_admin() || !$args['is_public'] || $args['is_raw']) {
149
+        ] );
150
+        if( is_admin() || !$args['is_public'] || $args['is_raw'] ) {
151 151
             return false;
152 152
         }
153 153
         return true;
Please login to merge, or discard this patch.
plugin/Modules/Migrate.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function isMigrationNeeded()
33 33
     {
34
-        $transient = get_transient($this->transientKey);
35
-        if (false === $transient || !isset($transient[glsr()->version])) {
34
+        $transient = get_transient( $this->transientKey );
35
+        if( false === $transient || !isset($transient[glsr()->version]) ) {
36 36
             $transient = [
37 37
                 glsr()->version => !empty($this->getNewMigrationFiles()),
38 38
             ];
39
-            set_transient($this->transientKey, $transient);
39
+            set_transient( $this->transientKey, $transient );
40 40
         }
41
-        return Helper::castToBool($transient[glsr()->version]);
41
+        return Helper::castToBool( $transient[glsr()->version] );
42 42
     }
43 43
 
44 44
     /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function run()
48 48
     {
49
-        return $this->runMigrations($this->getNewMigrationFiles());
49
+        return $this->runMigrations( $this->getNewMigrationFiles() );
50 50
     }
51 51
 
52 52
     /**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function runAll()
56 56
     {
57
-        return $this->runMigrations($this->getMigrationFiles());
57
+        return $this->runMigrations( $this->getMigrationFiles() );
58 58
     }
59 59
 
60 60
     /**
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $fallback = '0.0.0';
66 66
         $majorVersions = [4, 3, 2, 1];
67
-        foreach ($majorVersions as $majorVersion) {
68
-            $settings = get_option(OptionManager::databaseKey($majorVersion));
69
-            $version = Arr::get($settings, 'version', $fallback);
70
-            if (Helper::isGreaterThan($version, $fallback)) {
67
+        foreach( $majorVersions as $majorVersion ) {
68
+            $settings = get_option( OptionManager::databaseKey( $majorVersion ) );
69
+            $version = Arr::get( $settings, 'version', $fallback );
70
+            if( Helper::isGreaterThan( $version, $fallback ) ) {
71 71
                 return $version;
72 72
             }
73 73
         }
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
     protected function getMigrationFiles()
81 81
     {
82 82
         $files = [];
83
-        $dir = glsr()->path('plugin/Modules/Migrations');
84
-        if (is_dir($dir)) {
85
-            $iterator = new DirectoryIterator($dir);
86
-            foreach ($iterator as $fileinfo) {
87
-                if ($fileinfo->isFile()) {
83
+        $dir = glsr()->path( 'plugin/Modules/Migrations' );
84
+        if( is_dir( $dir ) ) {
85
+            $iterator = new DirectoryIterator( $dir );
86
+            foreach( $iterator as $fileinfo ) {
87
+                if( $fileinfo->isFile() ) {
88 88
                     $files[] = $fileinfo->getFilename();
89 89
                 }
90 90
             }
91
-            natsort($files);
91
+            natsort( $files );
92 92
         }
93 93
         return $files;
94 94
     }
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
     protected function getNewMigrationFiles()
100 100
     {
101 101
         $files = $this->getMigrationFiles();
102
-        foreach ($files as $index => $file) {
103
-            $className = str_replace('.php', '', $file);
104
-            $migrationVersion = str_replace(['Migrate_', '_'], ['', '.'], $className);
105
-            $suffix = preg_replace('/[\d.]+(.+)?/', '${1}', glsr()->version); // allow alpha/beta versions
106
-            if (Helper::isGreaterThanOrEqual($this->currentVersion, $migrationVersion.$suffix)) {
102
+        foreach( $files as $index => $file ) {
103
+            $className = str_replace( '.php', '', $file );
104
+            $migrationVersion = str_replace( ['Migrate_', '_'], ['', '.'], $className );
105
+            $suffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions
106
+            if( Helper::isGreaterThanOrEqual( $this->currentVersion, $migrationVersion.$suffix ) ) {
107 107
                 unset($files[$index]);
108 108
             }
109 109
         }
@@ -113,22 +113,22 @@  discard block
 block discarded – undo
113 113
     /**
114 114
      * @return bool
115 115
      */
116
-    protected function runMigrations(array $files)
116
+    protected function runMigrations( array $files )
117 117
     {
118
-        if (empty($files)) {
118
+        if( empty($files) ) {
119 119
             return false;
120 120
         }
121
-        array_walk($files, function ($file) {
122
-            $className = str_replace('.php', '', $file);
123
-            glsr('Modules\\Migrations\\'.$className)->run();
124
-            $versionMigrated = str_replace(['Migrate_', '_'], ['v','.'], $className);
125
-            glsr_log()->debug('migration completed for '.$versionMigrated);
121
+        array_walk( $files, function( $file ) {
122
+            $className = str_replace( '.php', '', $file );
123
+            glsr( 'Modules\\Migrations\\'.$className )->run();
124
+            $versionMigrated = str_replace( ['Migrate_', '_'], ['v', '.'], $className );
125
+            glsr_log()->debug( 'migration completed for '.$versionMigrated );
126 126
         });
127
-        if ($this->currentVersion !== glsr()->version) {
128
-            $this->updateVersionFrom($this->currentVersion);
127
+        if( $this->currentVersion !== glsr()->version ) {
128
+            $this->updateVersionFrom( $this->currentVersion );
129 129
         }
130
-        glsr(OptionManager::class)->set('last_migration_run', current_time('timestamp'));
131
-        delete_transient($this->transientKey);
130
+        glsr( OptionManager::class )->set( 'last_migration_run', current_time( 'timestamp' ) );
131
+        delete_transient( $this->transientKey );
132 132
         return true;
133 133
     }
134 134
 
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
      * @param string $previousVersion
137 137
      * @return void
138 138
      */
139
-    protected function updateVersionFrom($previousVersion)
139
+    protected function updateVersionFrom( $previousVersion )
140 140
     {
141
-        glsr(OptionManager::class)->set('version', glsr()->version);
142
-        glsr(OptionManager::class)->set('version_upgraded_from', $previousVersion);
141
+        glsr( OptionManager::class )->set( 'version', glsr()->version );
142
+        glsr( OptionManager::class )->set( 'version_upgraded_from', $previousVersion );
143 143
     }
144 144
 }
Please login to merge, or discard this patch.
plugin/Modules/Console.php 1 patch
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
 
11 11
 class Console
12 12
 {
13
-    const DEBUG = 0;      // Detailed debug information
14
-    const INFO = 1;       // Interesting events
15
-    const NOTICE = 2;     // Normal but significant events
16
-    const WARNING = 4;    // Exceptional occurrences that are not errors
17
-    const ERROR = 8;      // Runtime errors that do not require immediate action
18
-    const CRITICAL = 16;  // Critical conditions
19
-    const ALERT = 32;     // Action must be taken immediately
13
+    const DEBUG = 0; // Detailed debug information
14
+    const INFO = 1; // Interesting events
15
+    const NOTICE = 2; // Normal but significant events
16
+    const WARNING = 4; // Exceptional occurrences that are not errors
17
+    const ERROR = 8; // Runtime errors that do not require immediate action
18
+    const CRITICAL = 16; // Critical conditions
19
+    const ALERT = 32; // Action must be taken immediately
20 20
     const EMERGENCY = 64; // System is unusable
21 21
 
22 22
     protected $file;
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function __construct()
27 27
     {
28
-        $this->file = glsr()->path('console.log');
29
-        $this->log = file_exists($this->file)
30
-            ? file_get_contents($this->file)
28
+        $this->file = glsr()->path( 'console.log' );
29
+        $this->log = file_exists( $this->file )
30
+            ? file_get_contents( $this->file )
31 31
             : '';
32 32
         $this->reset();
33 33
     }
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
      * @param array $context
48 48
      * @return static
49 49
      */
50
-    public function alert($message, array $context = [])
50
+    public function alert( $message, array $context = [] )
51 51
     {
52
-        return $this->log(static::ALERT, $message, $context);
52
+        return $this->log( static::ALERT, $message, $context );
53 53
     }
54 54
 
55 55
     /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     public function clear()
59 59
     {
60 60
         $this->log = '';
61
-        file_put_contents($this->file, $this->log);
61
+        file_put_contents( $this->file, $this->log );
62 62
     }
63 63
 
64 64
     /**
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
      * @param array $context
69 69
      * @return static
70 70
      */
71
-    public function critical($message, array $context = [])
71
+    public function critical( $message, array $context = [] )
72 72
     {
73
-        return $this->log(static::CRITICAL, $message, $context);
73
+        return $this->log( static::CRITICAL, $message, $context );
74 74
     }
75 75
 
76 76
     /**
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
      * @param array $context
80 80
      * @return static
81 81
      */
82
-    public function debug($message, array $context = [])
82
+    public function debug( $message, array $context = [] )
83 83
     {
84
-        return $this->log(static::DEBUG, $message, $context);
84
+        return $this->log( static::DEBUG, $message, $context );
85 85
     }
86 86
 
87 87
     /**
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
      * @param array $context
91 91
      * @return static
92 92
      */
93
-    public function emergency($message, array $context = [])
93
+    public function emergency( $message, array $context = [] )
94 94
     {
95
-        return $this->log(static::EMERGENCY, $message, $context);
95
+        return $this->log( static::EMERGENCY, $message, $context );
96 96
     }
97 97
 
98 98
     /**
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
      * @param array $context
102 102
      * @return static
103 103
      */
104
-    public function error($message, array $context = [])
104
+    public function error( $message, array $context = [] )
105 105
     {
106
-        return $this->log(static::ERROR, $message, $context);
106
+        return $this->log( static::ERROR, $message, $context );
107 107
     }
108 108
 
109 109
     /**
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     public function get()
113 113
     {
114 114
         return empty($this->log)
115
-            ? __('Console is empty', 'site-reviews')
115
+            ? __( 'Console is empty', 'site-reviews' )
116 116
             : $this->log;
117 117
     }
118 118
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function getLevel()
123 123
     {
124
-        return intval(apply_filters('site-reviews/console/level', static::INFO));
124
+        return intval( apply_filters( 'site-reviews/console/level', static::INFO ) );
125 125
     }
126 126
 
127 127
     /**
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function getLevels()
131 131
     {
132
-        $constants = (new ReflectionClass(__CLASS__))->getConstants();
133
-        return array_map('strtolower', array_flip($constants));
132
+        $constants = (new ReflectionClass( __CLASS__ ))->getConstants();
133
+        return array_map( 'strtolower', array_flip( $constants ) );
134 134
     }
135 135
 
136 136
     /**
@@ -139,21 +139,21 @@  discard block
 block discarded – undo
139 139
     public function humanLevel()
140 140
     {
141 141
         $level = $this->getLevel();
142
-        return sprintf('%s (%d)', strtoupper(Arr::get($this->getLevels(), $level, 'unknown')), $level);
142
+        return sprintf( '%s (%d)', strtoupper( Arr::get( $this->getLevels(), $level, 'unknown' ) ), $level );
143 143
     }
144 144
 
145 145
     /**
146 146
      * @param string|null $valueIfEmpty
147 147
      * @return string
148 148
      */
149
-    public function humanSize($valueIfEmpty = null)
149
+    public function humanSize( $valueIfEmpty = null )
150 150
     {
151 151
         $bytes = $this->size();
152
-        if (empty($bytes) && is_string($valueIfEmpty)) {
152
+        if( empty($bytes) && is_string( $valueIfEmpty ) ) {
153 153
             return $valueIfEmpty;
154 154
         }
155
-        $exponent = floor(log(max($bytes, 1), 1024));
156
-        return round($bytes / pow(1024, $exponent), 2).' '.['bytes', 'KB', 'MB', 'GB'][$exponent];
155
+        $exponent = floor( log( max( $bytes, 1 ), 1024 ) );
156
+        return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes', 'KB', 'MB', 'GB'][$exponent];
157 157
     }
158 158
 
159 159
     /**
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
      * @param array $context
164 164
      * @return static
165 165
      */
166
-    public function info($message, array $context = [])
166
+    public function info( $message, array $context = [] )
167 167
     {
168
-        return $this->log(static::INFO, $message, $context);
168
+        return $this->log( static::INFO, $message, $context );
169 169
     }
170 170
 
171 171
     /**
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
      * @param string $backtraceLine
176 176
      * @return static
177 177
      */
178
-    public function log($level, $message, $context = [], $backtraceLine = '')
178
+    public function log( $level, $message, $context = [], $backtraceLine = '' )
179 179
     {
180
-        if (empty($backtraceLine)) {
180
+        if( empty($backtraceLine) ) {
181 181
             $backtraceLine = $this->getBacktraceLine();
182 182
         }
183
-        if ($this->canLogEntry($level, $backtraceLine)) {
184
-            $levelName = Arr::get($this->getLevels(), $level);
185
-            $context = Arr::consolidate($context);
186
-            $backtraceLine = $this->normalizeBacktraceLine($backtraceLine);
187
-            $message = $this->interpolate($message, $context);
188
-            $entry = $this->buildLogEntry($levelName, $message, $backtraceLine);
189
-            file_put_contents($this->file, $entry.PHP_EOL, FILE_APPEND | LOCK_EX);
190
-            apply_filters('console', $message, $levelName, $backtraceLine); // Show in Blackbar plugin if installed
183
+        if( $this->canLogEntry( $level, $backtraceLine ) ) {
184
+            $levelName = Arr::get( $this->getLevels(), $level );
185
+            $context = Arr::consolidate( $context );
186
+            $backtraceLine = $this->normalizeBacktraceLine( $backtraceLine );
187
+            $message = $this->interpolate( $message, $context );
188
+            $entry = $this->buildLogEntry( $levelName, $message, $backtraceLine );
189
+            file_put_contents( $this->file, $entry.PHP_EOL, FILE_APPEND | LOCK_EX );
190
+            apply_filters( 'console', $message, $levelName, $backtraceLine ); // Show in Blackbar plugin if installed
191 191
             $this->reset();
192 192
         }
193 193
         return $this;
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
      */
199 199
     public function logOnce()
200 200
     {
201
-        $once = Arr::consolidate(glsr()->{$this->logOnceKey});
201
+        $once = Arr::consolidate( glsr()->{$this->logOnceKey});
202 202
         $levels = $this->getLevels();
203
-        foreach ($once as $entry) {
204
-            $levelName = Arr::get($entry, 'level');
205
-            if (!in_array($levelName, $levels)) {
203
+        foreach( $once as $entry ) {
204
+            $levelName = Arr::get( $entry, 'level' );
205
+            if( !in_array( $levelName, $levels ) ) {
206 206
                 continue;
207 207
             }
208
-            $level = Arr::get(array_flip($levels), $levelName);
209
-            $message = Arr::get($entry, 'message');
210
-            $backtraceLine = Arr::get($entry, 'backtrace');
211
-            $this->log($level, $message, [], $backtraceLine);
208
+            $level = Arr::get( array_flip( $levels ), $levelName );
209
+            $message = Arr::get( $entry, 'message' );
210
+            $backtraceLine = Arr::get( $entry, 'backtrace' );
211
+            $this->log( $level, $message, [], $backtraceLine );
212 212
         }
213 213
         glsr()->{$this->logOnceKey} = [];
214 214
     }
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
      * @param array $context
220 220
      * @return static
221 221
      */
222
-    public function notice($message, array $context = [])
222
+    public function notice( $message, array $context = [] )
223 223
     {
224
-        return $this->log(static::NOTICE, $message, $context);
224
+        return $this->log( static::NOTICE, $message, $context );
225 225
     }
226 226
 
227 227
     /**
@@ -230,21 +230,21 @@  discard block
 block discarded – undo
230 230
      * @param mixed $data
231 231
      * @return void
232 232
      */
233
-    public function once($levelName, $handle, $data)
233
+    public function once( $levelName, $handle, $data )
234 234
     {
235
-        $once = Arr::consolidate(glsr()->{$this->logOnceKey});
236
-        $filtered = array_filter($once, function ($entry) use ($levelName, $handle) {
237
-            return Arr::get($entry, 'level') == $levelName
238
-                && Arr::get($entry, 'handle') == $handle;
235
+        $once = Arr::consolidate( glsr()->{$this->logOnceKey});
236
+        $filtered = array_filter( $once, function( $entry ) use ($levelName, $handle) {
237
+            return Arr::get( $entry, 'level' ) == $levelName
238
+                && Arr::get( $entry, 'handle' ) == $handle;
239 239
         });
240
-        if (!empty($filtered)) {
240
+        if( !empty($filtered) ) {
241 241
             return;
242 242
         }
243 243
         $once[] = [
244
-            'backtrace' => $this->getBacktraceLineFromData($data),
244
+            'backtrace' => $this->getBacktraceLineFromData( $data ),
245 245
             'handle' => $handle,
246 246
             'level' => $levelName,
247
-            'message' => '[RECURRING] '.$this->getMessageFromData($data),
247
+            'message' => '[RECURRING] '.$this->getMessageFromData( $data ),
248 248
         ];
249 249
         glsr()->{$this->logOnceKey} = $once;
250 250
     }
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function size()
256 256
     {
257
-        return file_exists($this->file)
258
-            ? filesize($this->file)
257
+        return file_exists( $this->file )
258
+            ? filesize( $this->file )
259 259
             : 0;
260 260
     }
261 261
 
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
      * @param array $context
267 267
      * @return static
268 268
      */
269
-    public function warning($message, array $context = [])
269
+    public function warning( $message, array $context = [] )
270 270
     {
271
-        return $this->log(static::WARNING, $message, $context);
271
+        return $this->log( static::WARNING, $message, $context );
272 272
     }
273 273
 
274 274
     /**
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
      * @param int $index
277 277
      * @return string
278 278
      */
279
-    protected function buildBacktraceLine($backtrace, $index)
279
+    protected function buildBacktraceLine( $backtrace, $index )
280 280
     {
281
-        return sprintf('%s:%s',
282
-            Arr::get($backtrace, $index.'.file'), // realpath
283
-            Arr::get($backtrace, $index.'.line')
281
+        return sprintf( '%s:%s',
282
+            Arr::get( $backtrace, $index.'.file' ), // realpath
283
+            Arr::get( $backtrace, $index.'.line' )
284 284
         );
285 285
     }
286 286
 
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
      * @param string $backtraceLine
291 291
      * @return string
292 292
      */
293
-    protected function buildLogEntry($levelName, $message, $backtraceLine = '')
293
+    protected function buildLogEntry( $levelName, $message, $backtraceLine = '' )
294 294
     {
295
-        return sprintf('[%s] %s [%s] %s',
296
-            current_time('mysql'),
297
-            strtoupper($levelName),
295
+        return sprintf( '[%s] %s [%s] %s',
296
+            current_time( 'mysql' ),
297
+            strtoupper( $levelName ),
298 298
             $backtraceLine,
299 299
             $message
300 300
         );
@@ -304,10 +304,10 @@  discard block
 block discarded – undo
304 304
      * @param int $level
305 305
      * @return bool
306 306
      */
307
-    protected function canLogEntry($level, $backtraceLine)
307
+    protected function canLogEntry( $level, $backtraceLine )
308 308
     {
309
-        $levelExists = array_key_exists($level, $this->getLevels());
310
-        if (!Str::contains($backtraceLine, glsr()->path())) {
309
+        $levelExists = array_key_exists( $level, $this->getLevels() );
310
+        if( !Str::contains( $backtraceLine, glsr()->path() ) ) {
311 311
             return $levelExists; // ignore level restriction if triggered outside of the plugin
312 312
         }
313 313
         return $levelExists && $level >= $this->getLevel();
@@ -318,17 +318,17 @@  discard block
 block discarded – undo
318 318
      */
319 319
     protected function getBacktraceLine()
320 320
     {
321
-        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6);
322
-        $search = array_search('glsr_log', glsr_array_column($backtrace, 'function'));
323
-        if (false !== $search) {
324
-            return $this->buildBacktraceLine($backtrace, (int) $search);
321
+        $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 6 );
322
+        $search = array_search( 'glsr_log', glsr_array_column( $backtrace, 'function' ) );
323
+        if( false !== $search ) {
324
+            return $this->buildBacktraceLine( $backtrace, (int)$search );
325 325
         }
326
-        $search = array_search('log', glsr_array_column($backtrace, 'function'));
327
-        if (false !== $search) {
328
-            $index = '{closure}' == Arr::get($backtrace, ($search + 2).'.function')
326
+        $search = array_search( 'log', glsr_array_column( $backtrace, 'function' ) );
327
+        if( false !== $search ) {
328
+            $index = '{closure}' == Arr::get( $backtrace, ($search + 2).'.function' )
329 329
                 ? $search + 4
330 330
                 : $search + 1;
331
-            return $this->buildBacktraceLine($backtrace, $index);
331
+            return $this->buildBacktraceLine( $backtrace, $index );
332 332
         }
333 333
         return 'Unknown';
334 334
     }
@@ -337,23 +337,23 @@  discard block
 block discarded – undo
337 337
      * @param mixed $data
338 338
      * @return string
339 339
      */
340
-    protected function getBacktraceLineFromData($data)
340
+    protected function getBacktraceLineFromData( $data )
341 341
     {
342 342
         $backtrace = $data instanceof Throwable
343 343
             ? $data->getTrace()
344
-            : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
345
-        return $this->buildBacktraceLine($backtrace, 0);
344
+            : debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1 );
345
+        return $this->buildBacktraceLine( $backtrace, 0 );
346 346
     }
347 347
 
348 348
     /**
349 349
      * @param mixed $data
350 350
      * @return string
351 351
      */
352
-    protected function getMessageFromData($data)
352
+    protected function getMessageFromData( $data )
353 353
     {
354 354
         return $data instanceof Throwable
355
-            ? $this->normalizeThrowableMessage($data->getMessage())
356
-            : print_r($data, 1);
355
+            ? $this->normalizeThrowableMessage( $data->getMessage() )
356
+            : print_r( $data, 1 );
357 357
     }
358 358
 
359 359
     /**
@@ -362,53 +362,53 @@  discard block
 block discarded – undo
362 362
      * @param array $context
363 363
      * @return string
364 364
      */
365
-    protected function interpolate($message, $context = [])
365
+    protected function interpolate( $message, $context = [] )
366 366
     {
367
-        if ($this->isObjectOrArray($message) || !is_array($context)) {
368
-            return print_r($message, true);
367
+        if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) {
368
+            return print_r( $message, true );
369 369
         }
370 370
         $replace = [];
371
-        foreach ($context as $key => $value) {
372
-            $replace['{'.$key.'}'] = $this->normalizeValue($value);
371
+        foreach( $context as $key => $value ) {
372
+            $replace['{'.$key.'}'] = $this->normalizeValue( $value );
373 373
         }
374
-        return strtr($message, $replace);
374
+        return strtr( $message, $replace );
375 375
     }
376 376
 
377 377
     /**
378 378
      * @param mixed $value
379 379
      * @return bool
380 380
      */
381
-    protected function isObjectOrArray($value)
381
+    protected function isObjectOrArray( $value )
382 382
     {
383
-        return is_object($value) || is_array($value);
383
+        return is_object( $value ) || is_array( $value );
384 384
     }
385 385
 
386 386
     /**
387 387
      * @param string $backtraceLine
388 388
      * @return string
389 389
      */
390
-    protected function normalizeBacktraceLine($backtraceLine)
390
+    protected function normalizeBacktraceLine( $backtraceLine )
391 391
     {
392 392
         $search = [
393
-            glsr()->path('plugin/'),
394
-            glsr()->path('plugin/', false),
395
-            trailingslashit(glsr()->path()),
396
-            trailingslashit(glsr()->path('', false)),
393
+            glsr()->path( 'plugin/' ),
394
+            glsr()->path( 'plugin/', false ),
395
+            trailingslashit( glsr()->path() ),
396
+            trailingslashit( glsr()->path( '', false ) ),
397 397
             WP_CONTENT_DIR,
398 398
             ABSPATH,
399 399
         ];
400
-        return str_replace(array_unique($search), '', $backtraceLine);
400
+        return str_replace( array_unique( $search ), '', $backtraceLine );
401 401
     }
402 402
 
403 403
     /**
404 404
      * @param string $message
405 405
      * @return string
406 406
      */
407
-    protected function normalizeThrowableMessage($message)
407
+    protected function normalizeThrowableMessage( $message )
408 408
     {
409
-        $calledIn = strpos($message, ', called in');
409
+        $calledIn = strpos( $message, ', called in' );
410 410
         return false !== $calledIn
411
-            ? substr($message, 0, $calledIn)
411
+            ? substr( $message, 0, $calledIn )
412 412
             : $message;
413 413
     }
414 414
 
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
      * @param mixed $value
417 417
      * @return string
418 418
      */
419
-    protected function normalizeValue($value)
419
+    protected function normalizeValue( $value )
420 420
     {
421
-        if ($value instanceof DateTime) {
422
-            $value = $value->format('Y-m-d H:i:s');
423
-        } elseif ($this->isObjectOrArray($value)) {
424
-            $value = json_encode($value);
421
+        if( $value instanceof DateTime ) {
422
+            $value = $value->format( 'Y-m-d H:i:s' );
423
+        } elseif( $this->isObjectOrArray( $value ) ) {
424
+            $value = json_encode( $value );
425 425
         }
426
-        return (string) $value;
426
+        return (string)$value;
427 427
     }
428 428
 
429 429
     /**
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
      */
432 432
     protected function reset()
433 433
     {
434
-        if ($this->size() <= pow(1024, 2) / 8) {
434
+        if( $this->size() <= pow( 1024, 2 ) / 8 ) {
435 435
             return;
436 436
         }
437 437
         $this->clear();
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
             $this->file,
440 440
             $this->buildLogEntry(
441 441
                 static::NOTICE,
442
-                __('Console was automatically cleared (128 KB maximum size)', 'site-reviews')
442
+                __( 'Console was automatically cleared (128 KB maximum size)', 'site-reviews' )
443 443
             )
444 444
         );
445 445
     }
Please login to merge, or discard this patch.
plugin/Application.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
     public function __construct()
42 42
     {
43 43
         static::$instance = $this;
44
-        $this->file = str_replace('plugin/Application', static::ID, (new ReflectionClass($this))->getFileName());
45
-        $plugin = get_file_data($this->file, [
44
+        $this->file = str_replace( 'plugin/Application', static::ID, (new ReflectionClass( $this ))->getFileName() );
45
+        $plugin = get_file_data( $this->file, [
46 46
             'languages' => 'Domain Path',
47 47
             'name' => 'Plugin Name',
48 48
             'version' => 'Version',
49
-        ], 'plugin');
50
-        array_walk($plugin, function ($value, $key) {
49
+        ], 'plugin' );
50
+        array_walk( $plugin, function( $value, $key ) {
51 51
             $this->$key = $value;
52 52
         });
53 53
     }
@@ -58,17 +58,17 @@  discard block
 block discarded – undo
58 58
     public function activate()
59 59
     {
60 60
         $this->scheduleCronJob();
61
-        add_option(static::ID.'activated', true);
61
+        add_option( static::ID.'activated', true );
62 62
     }
63 63
 
64 64
     /**
65 65
      * @param string $view
66 66
      * @return string
67 67
      */
68
-    public function build($view, array $data = [])
68
+    public function build( $view, array $data = [] )
69 69
     {
70 70
         ob_start();
71
-        $this->render($view, $data);
71
+        $this->render( $view, $data );
72 72
         return ob_get_clean();
73 73
     }
74 74
 
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
      * @param string $capability
77 77
      * @return bool
78 78
      */
79
-    public function can($capability)
79
+    public function can( $capability )
80 80
     {
81
-        return $this->make(Role::class)->can($capability);
81
+        return $this->make( Role::class )->can( $capability );
82 82
     }
83 83
 
84 84
     /**
@@ -87,35 +87,35 @@  discard block
 block discarded – undo
87 87
     public function catchFatalError()
88 88
     {
89 89
         $error = error_get_last();
90
-        if (E_ERROR !== $error['type'] || !Str::contains($error['message'], $this->path())) {
90
+        if( E_ERROR !== $error['type'] || !Str::contains( $error['message'], $this->path() ) ) {
91 91
             return;
92 92
         }
93
-        glsr_log()->error($error['message']);
93
+        glsr_log()->error( $error['message'] );
94 94
     }
95 95
 
96 96
     /**
97 97
      * @param string $name
98 98
      * @return array
99 99
      */
100
-    public function config($name)
100
+    public function config( $name )
101 101
     {
102
-        $path = apply_filters('site-reviews/config', 'config/'.$name.'.php');
103
-        $configFile = $this->path($path);
104
-        $config = file_exists($configFile)
102
+        $path = apply_filters( 'site-reviews/config', 'config/'.$name.'.php' );
103
+        $configFile = $this->path( $path );
104
+        $config = file_exists( $configFile )
105 105
             ? include $configFile
106 106
             : [];
107
-        return apply_filters('site-reviews/config/'.$name, $config);
107
+        return apply_filters( 'site-reviews/config/'.$name, $config );
108 108
     }
109 109
 
110 110
     /**
111 111
      * @param string $property
112 112
      * @return string
113 113
      */
114
-    public function constant($property, $className = 'static')
114
+    public function constant( $property, $className = 'static' )
115 115
     {
116 116
         $constant = $className.'::'.$property;
117
-        return defined($constant)
118
-            ? apply_filters('site-reviews/const/'.$property, constant($constant))
117
+        return defined( $constant )
118
+            ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) )
119 119
             : '';
120 120
     }
121 121
 
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
      * @param string $view
132 132
      * @return void|string
133 133
      */
134
-    public function file($view)
134
+    public function file( $view )
135 135
     {
136
-        $view.= '.php';
136
+        $view .= '.php';
137 137
         $filePaths = [];
138
-        if (Str::startsWith('templates/', $view)) {
139
-            $filePaths[] = $this->themePath(Str::removePrefix('templates/', $view));
138
+        if( Str::startsWith( 'templates/', $view ) ) {
139
+            $filePaths[] = $this->themePath( Str::removePrefix( 'templates/', $view ) );
140 140
         }
141
-        $filePaths[] = $this->path($view);
142
-        $filePaths[] = $this->path('views/'.$view);
143
-        foreach ($filePaths as $file) {
144
-            if (!file_exists($file)) {
141
+        $filePaths[] = $this->path( $view );
142
+        $filePaths[] = $this->path( 'views/'.$view );
143
+        foreach( $filePaths as $file ) {
144
+            if( !file_exists( $file ) ) {
145 145
                 continue;
146 146
             }
147 147
             return $file;
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function getDefaults()
155 155
     {
156
-        if (empty($this->defaults)) {
157
-            $this->defaults = $this->make(DefaultsManager::class)->get();
156
+        if( empty($this->defaults) ) {
157
+            $this->defaults = $this->make( DefaultsManager::class )->get();
158 158
         }
159
-        return apply_filters('site-reviews/get/defaults', $this->defaults);
159
+        return apply_filters( 'site-reviews/get/defaults', $this->defaults );
160 160
     }
161 161
 
162 162
     /**
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      * @param string $tab
165 165
      * @return string
166 166
      */
167
-    public function getPermission($page = '', $tab = 'index')
167
+    public function getPermission( $page = '', $tab = 'index' )
168 168
     {
169 169
         $fallback = 'edit_posts';
170 170
         $permissions = [
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
                 'system-info' => 'edit_others_posts',
186 186
             ]
187 187
         ];
188
-        $permission = Arr::get($permissions, $page, $fallback);
189
-        if (is_array($permission)) {
190
-            $permission = Arr::get($permission, $tab, $fallback);
188
+        $permission = Arr::get( $permissions, $page, $fallback );
189
+        if( is_array( $permission ) ) {
190
+            $permission = Arr::get( $permission, $tab, $fallback );
191 191
         }
192
-        return empty($permission) || !is_string($permission)
192
+        return empty($permission) || !is_string( $permission )
193 193
             ? $fallback
194 194
             : $permission;
195 195
     }
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
      * @param string $tab
200 200
      * @return bool
201 201
      */
202
-    public function hasPermission($page = '', $tab = 'index')
202
+    public function hasPermission( $page = '', $tab = 'index' )
203 203
     {
204 204
         $isAdmin = $this->isAdmin();
205
-        return !$isAdmin || ($isAdmin && $this->can($this->getPermission($page, $tab)));
205
+        return !$isAdmin || ($isAdmin && $this->can( $this->getPermission( $page, $tab ) ));
206 206
     }
207 207
 
208 208
     /**
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
      */
211 211
     public function init()
212 212
     {
213
-        $this->make(Actions::class)->run();
214
-        $this->make(Filters::class)->run();
213
+        $this->make( Actions::class )->run();
214
+        $this->make( Filters::class )->run();
215 215
     }
216 216
 
217 217
     /**
@@ -226,31 +226,31 @@  discard block
 block discarded – undo
226 226
      * @param string $file
227 227
      * @return string
228 228
      */
229
-    public function path($file = '', $realpath = true)
229
+    public function path( $file = '', $realpath = true )
230 230
     {
231
-        $path = plugin_dir_path($this->file);
232
-        if (!$realpath) {
233
-            $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file));
231
+        $path = plugin_dir_path( $this->file );
232
+        if( !$realpath ) {
233
+            $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file ) );
234 234
         }
235
-        $path = trailingslashit($path).ltrim(trim($file), '/');
236
-        return apply_filters('site-reviews/path', $path, $file);
235
+        $path = trailingslashit( $path ).ltrim( trim( $file ), '/' );
236
+        return apply_filters( 'site-reviews/path', $path, $file );
237 237
     }
238 238
 
239 239
     /**
240 240
      * @param object $addon
241 241
      * @return void
242 242
      */
243
-    public function register($addon)
243
+    public function register( $addon )
244 244
     {
245 245
         try {
246
-            $reflection = new \ReflectionClass($addon);
247
-            if ($id = $reflection->getConstant('ID')) {
246
+            $reflection = new \ReflectionClass( $addon );
247
+            if( $id = $reflection->getConstant( 'ID' ) ) {
248 248
                 $this->addons[] = $id;
249
-                $this->bind($id, $addon);
249
+                $this->bind( $id, $addon );
250 250
                 $addon->init();
251 251
             }
252
-        } catch(\ReflectionException $e) {
253
-            glsr_log()->error('Attempted to register an invalid addon.');
252
+        } catch( \ReflectionException $e ) {
253
+            glsr_log()->error( 'Attempted to register an invalid addon.' );
254 254
         }
255 255
     }
256 256
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public function registerAddons()
261 261
     {
262
-        do_action('site-reviews/addon/register', $this);
262
+        do_action( 'site-reviews/addon/register', $this );
263 263
     }
264 264
 
265 265
     /**
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
      */
268 268
     public function registerLanguages()
269 269
     {
270
-        load_plugin_textdomain(static::ID, false,
271
-            trailingslashit(plugin_basename($this->path()).'/'.$this->languages)
270
+        load_plugin_textdomain( static::ID, false,
271
+            trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages )
272 272
         );
273 273
     }
274 274
 
@@ -277,26 +277,26 @@  discard block
 block discarded – undo
277 277
      */
278 278
     public function registerReviewTypes()
279 279
     {
280
-        $types = apply_filters('site-reviews/addon/types', []);
281
-        $this->reviewTypes = wp_parse_args($types, [
282
-            'local' => __('Local', 'site-reviews'),
283
-        ]);
280
+        $types = apply_filters( 'site-reviews/addon/types', [] );
281
+        $this->reviewTypes = wp_parse_args( $types, [
282
+            'local' => __( 'Local', 'site-reviews' ),
283
+        ] );
284 284
     }
285 285
 
286 286
     /**
287 287
      * @param string $view
288 288
      * @return void
289 289
      */
290
-    public function render($view, array $data = [])
290
+    public function render( $view, array $data = [] )
291 291
     {
292
-        $view = apply_filters('site-reviews/render/view', $view, $data);
293
-        $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data);
294
-        if (!file_exists($file)) {
295
-            glsr_log()->error(sprintf('File not found: (%s) %s', $view, $file));
292
+        $view = apply_filters( 'site-reviews/render/view', $view, $data );
293
+        $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data );
294
+        if( !file_exists( $file ) ) {
295
+            glsr_log()->error( sprintf( 'File not found: (%s) %s', $view, $file ) );
296 296
             return;
297 297
         }
298
-        $data = apply_filters('site-reviews/views/data', $data, $view);
299
-        extract($data);
298
+        $data = apply_filters( 'site-reviews/views/data', $data, $view );
299
+        extract( $data );
300 300
         include $file;
301 301
     }
302 302
 
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
      */
306 306
     public function scheduleCronJob()
307 307
     {
308
-        if (false === wp_next_scheduled(static::CRON_EVENT)) {
309
-            wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT);
308
+        if( false === wp_next_scheduled( static::CRON_EVENT ) ) {
309
+            wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT );
310 310
         }
311 311
     }
312 312
 
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function setDefaults()
317 317
     {
318
-        if (get_option(static::ID.'activated')) {
319
-            $this->make(DefaultsManager::class)->set();
320
-            delete_option(static::ID.'activated');
318
+        if( get_option( static::ID.'activated' ) ) {
319
+            $this->make( DefaultsManager::class )->set();
320
+            delete_option( static::ID.'activated' );
321 321
         }
322 322
     }
323 323
 
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
      * @param string $file
326 326
      * @return string
327 327
      */
328
-    public function themePath($file = '')
328
+    public function themePath( $file = '' )
329 329
     {
330
-        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/');
330
+        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim( trim( $file ), '/' );
331 331
     }
332 332
 
333 333
     /**
@@ -335,36 +335,36 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function unscheduleCronJob()
337 337
     {
338
-        wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT);
338
+        wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT );
339 339
     }
340 340
 
341 341
     /**
342 342
      * @param string $path
343 343
      * @return string
344 344
      */
345
-    public function url($path = '')
345
+    public function url( $path = '' )
346 346
     {
347
-        $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
348
-        return apply_filters('site-reviews/url', $url, $path);
347
+        $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) );
348
+        return apply_filters( 'site-reviews/url', $url, $path );
349 349
     }
350 350
 
351 351
     /**
352 352
      * @param string $versionLevel
353 353
      * @return string
354 354
      */
355
-    public function version($versionLevel = '')
355
+    public function version( $versionLevel = '' )
356 356
     {
357 357
         $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i';
358
-        preg_match($pattern, $this->version, $matches);
359
-        switch ($versionLevel) {
358
+        preg_match( $pattern, $this->version, $matches );
359
+        switch( $versionLevel ) {
360 360
             case 'major':
361
-                $version = Arr::get($matches, 1);
361
+                $version = Arr::get( $matches, 1 );
362 362
                 break;
363 363
             case 'minor':
364
-                $version = Arr::get($matches, 1).Arr::get($matches, 2);
364
+                $version = Arr::get( $matches, 1 ).Arr::get( $matches, 2 );
365 365
                 break;
366 366
             case 'patch':
367
-                $version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3);
367
+                $version = Arr::get( $matches, 1 ).Arr::get( $matches, 2 ).Arr::get( $matches, 3 );
368 368
                 break;
369 369
         }
370 370
         return empty($version)
Please login to merge, or discard this patch.
plugin/Handlers/RegisterWidgets.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@
 block discarded – undo
11 11
     /**
12 12
      * @return void
13 13
      */
14
-    public function handle(Command $command)
14
+    public function handle( Command $command )
15 15
     {
16
-        foreach ($command->widgets as $baseId => $args) {
17
-            $widgetClass = Helper::buildClassName($baseId.'-widget', 'Widgets');
18
-            if (!class_exists($widgetClass)) {
19
-                glsr_log()->error(sprintf('Widget class missing (%s)', $widgetClass));
16
+        foreach( $command->widgets as $baseId => $args ) {
17
+            $widgetClass = Helper::buildClassName( $baseId.'-widget', 'Widgets' );
18
+            if( !class_exists( $widgetClass ) ) {
19
+                glsr_log()->error( sprintf( 'Widget class missing (%s)', $widgetClass ) );
20 20
                 continue;
21 21
             }
22
-            register_widget(new $widgetClass(Application::PREFIX.$baseId, $args['name'], $args));
22
+            register_widget( new $widgetClass( Application::PREFIX.$baseId, $args['name'], $args ) );
23 23
         }
24 24
     }
25 25
 }
Please login to merge, or discard this patch.
plugin/Handlers/EnqueueAdminAssets.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
     /**
19 19
      * @return void
20 20
      */
21
-    public function handle(Command $command)
21
+    public function handle( Command $command )
22 22
     {
23
-        $this->generatePointers($command->pointers);
23
+        $this->generatePointers( $command->pointers );
24 24
         $this->enqueueAssets();
25 25
         $this->localizeAssets();
26 26
     }
@@ -30,25 +30,25 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function enqueueAssets()
32 32
     {
33
-        if (!$this->isCurrentScreen()) {
33
+        if( !$this->isCurrentScreen() ) {
34 34
             return;
35 35
         }
36 36
         wp_enqueue_style(
37 37
             Application::ID.'/admin',
38
-            glsr()->url('assets/styles/'.Application::ID.'-admin.css'),
38
+            glsr()->url( 'assets/styles/'.Application::ID.'-admin.css' ),
39 39
             [],
40 40
             glsr()->version
41 41
         );
42 42
         wp_enqueue_script(
43 43
             Application::ID.'/admin',
44
-            glsr()->url('assets/scripts/'.Application::ID.'-admin.js'),
44
+            glsr()->url( 'assets/scripts/'.Application::ID.'-admin.js' ),
45 45
             $this->getDependencies(),
46 46
             glsr()->version,
47 47
             true
48 48
         );
49
-        if (!empty($this->pointers)) {
50
-            wp_enqueue_style('wp-pointer');
51
-            wp_enqueue_script('wp-pointer');
49
+        if( !empty($this->pointers) ) {
50
+            wp_enqueue_style( 'wp-pointer' );
51
+            wp_enqueue_script( 'wp-pointer' );
52 52
         }
53 53
     }
54 54
 
@@ -60,33 +60,33 @@  discard block
 block discarded – undo
60 60
         $variables = [
61 61
             'action' => Application::PREFIX.'action',
62 62
             'addons' => [],
63
-            'ajaxurl' => admin_url('admin-ajax.php'),
63
+            'ajaxurl' => admin_url( 'admin-ajax.php' ),
64 64
             'hideoptions' => [
65
-                'site_reviews' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
66
-                'site_reviews_form' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
67
-                'site_reviews_summary' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
65
+                'site_reviews' => glsr( SiteReviewsShortcode::class )->getHideOptions(),
66
+                'site_reviews_form' => glsr( SiteReviewsFormShortcode::class )->getHideOptions(),
67
+                'site_reviews_summary' => glsr( SiteReviewsSummaryShortcode::class )->getHideOptions(),
68 68
             ],
69 69
             'nameprefix' => Application::ID,
70 70
             'nonce' => [
71
-                'change-status' => wp_create_nonce('change-status'),
72
-                'clear-console' => wp_create_nonce('clear-console'),
73
-                'count-reviews' => wp_create_nonce('count-reviews'),
74
-                'fetch-console' => wp_create_nonce('fetch-console'),
75
-                'mce-shortcode' => wp_create_nonce('mce-shortcode'),
76
-                'sync-reviews' => wp_create_nonce('sync-reviews'),
77
-                'toggle-pinned' => wp_create_nonce('toggle-pinned'),
71
+                'change-status' => wp_create_nonce( 'change-status' ),
72
+                'clear-console' => wp_create_nonce( 'clear-console' ),
73
+                'count-reviews' => wp_create_nonce( 'count-reviews' ),
74
+                'fetch-console' => wp_create_nonce( 'fetch-console' ),
75
+                'mce-shortcode' => wp_create_nonce( 'mce-shortcode' ),
76
+                'sync-reviews' => wp_create_nonce( 'sync-reviews' ),
77
+                'toggle-pinned' => wp_create_nonce( 'toggle-pinned' ),
78 78
             ],
79 79
             'pointers' => $this->pointers,
80 80
             'shortcodes' => [],
81 81
             'tinymce' => [
82
-                'glsr_shortcode' => glsr()->url('assets/scripts/mce-plugin.js'),
82
+                'glsr_shortcode' => glsr()->url( 'assets/scripts/mce-plugin.js' ),
83 83
             ],
84 84
         ];
85
-        if (user_can_richedit()) {
85
+        if( user_can_richedit() ) {
86 86
             $variables['shortcodes'] = $this->localizeShortcodes();
87 87
         }
88
-        $variables = apply_filters('site-reviews/enqueue/admin/localize', $variables);
89
-        wp_localize_script(Application::ID.'/admin', 'GLSR', $variables);
88
+        $variables = apply_filters( 'site-reviews/enqueue/admin/localize', $variables );
89
+        wp_localize_script( Application::ID.'/admin', 'GLSR', $variables );
90 90
     }
91 91
 
92 92
     /**
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
      */
95 95
     protected function getDependencies()
96 96
     {
97
-        $dependencies = apply_filters('site-reviews/enqueue/admin/dependencies', []);
98
-        $dependencies = array_merge($dependencies, [
97
+        $dependencies = apply_filters( 'site-reviews/enqueue/admin/dependencies', [] );
98
+        $dependencies = array_merge( $dependencies, [
99 99
             'jquery', 'jquery-ui-sortable', 'underscore', 'wp-util',
100
-        ]);
100
+        ] );
101 101
         return $dependencies;
102 102
     }
103 103
 
104 104
     /**
105 105
      * @return array
106 106
      */
107
-    protected function generatePointer(array $pointer)
107
+    protected function generatePointer( array $pointer )
108 108
     {
109 109
         return [
110 110
             'id' => $pointer['id'],
@@ -120,19 +120,19 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * @return void
122 122
      */
123
-    protected function generatePointers(array $pointers)
123
+    protected function generatePointers( array $pointers )
124 124
     {
125
-        $dismissedPointers = get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true);
126
-        $dismissedPointers = explode(',', (string) $dismissedPointers);
125
+        $dismissedPointers = get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true );
126
+        $dismissedPointers = explode( ',', (string)$dismissedPointers );
127 127
         $generatedPointers = [];
128
-        foreach ($pointers as $pointer) {
129
-            if ($pointer['screen'] != glsr_current_screen()->id) {
128
+        foreach( $pointers as $pointer ) {
129
+            if( $pointer['screen'] != glsr_current_screen()->id ) {
130 130
                 continue;
131 131
             }
132
-            if (in_array($pointer['id'], $dismissedPointers)) {
132
+            if( in_array( $pointer['id'], $dismissedPointers ) ) {
133 133
                 continue;
134 134
             }
135
-            $generatedPointers[] = $this->generatePointer($pointer);
135
+            $generatedPointers[] = $this->generatePointer( $pointer );
136 136
         }
137 137
         $this->pointers = $generatedPointers;
138 138
     }
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
     protected function localizeShortcodes()
157 157
     {
158 158
         $variables = [];
159
-        foreach (glsr()->mceShortcodes as $tag => $args) {
160
-            if (empty($args['required'])) {
159
+        foreach( glsr()->mceShortcodes as $tag => $args ) {
160
+            if( empty($args['required']) ) {
161 161
                 continue;
162 162
             }
163 163
             $variables[$tag] = $args['required'];
Please login to merge, or discard this patch.
plugin/Handlers/RegisterShortcodes.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@
 block discarded – undo
10 10
     /**
11 11
      * @return void
12 12
      */
13
-    public function handle(Command $command)
13
+    public function handle( Command $command )
14 14
     {
15
-        foreach ($command->shortcodes as $shortcode) {
16
-            $shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes');
17
-            if (!class_exists($shortcodeClass)) {
18
-                glsr_log()->error(sprintf('Shortcode class missing (%s)', $shortcodeClass));
15
+        foreach( $command->shortcodes as $shortcode ) {
16
+            $shortcodeClass = Helper::buildClassName( $shortcode.'-shortcode', 'Shortcodes' );
17
+            if( !class_exists( $shortcodeClass ) ) {
18
+                glsr_log()->error( sprintf( 'Shortcode class missing (%s)', $shortcodeClass ) );
19 19
                 continue;
20 20
             }
21
-            add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']);
21
+            add_shortcode( $shortcode, [glsr( $shortcodeClass ), 'buildShortcode'] );
22 22
         }
23 23
     }
24 24
 }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterTinymcePopups.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,18 +10,18 @@
 block discarded – undo
10 10
     /**
11 11
      * @return void
12 12
      */
13
-    public function handle(Command $command)
13
+    public function handle( Command $command )
14 14
     {
15
-        foreach ($command->popups as $slug => $label) {
16
-            $buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes');
17
-            if (!class_exists($buttonClass)) {
18
-                glsr_log()->error(sprintf('Tinymce Popup class missing (%s)', $buttonClass));
15
+        foreach( $command->popups as $slug => $label ) {
16
+            $buttonClass = Helper::buildClassName( $slug.'-popup', 'Shortcodes' );
17
+            if( !class_exists( $buttonClass ) ) {
18
+                glsr_log()->error( sprintf( 'Tinymce Popup class missing (%s)', $buttonClass ) );
19 19
                 continue;
20 20
             }
21
-            $shortcode = glsr($buttonClass)->register($slug, [
21
+            $shortcode = glsr( $buttonClass )->register( $slug, [
22 22
                 'label' => $label,
23 23
                 'title' => $label,
24
-            ]);
24
+            ] );
25 25
             glsr()->mceShortcodes[$slug] = $shortcode->properties;
26 26
         }
27 27
     }
Please login to merge, or discard this patch.
plugin/Review.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -33,27 +33,27 @@  discard block
 block discarded – undo
33 33
     public $url;
34 34
     public $user_id;
35 35
 
36
-    public function __construct(WP_Post $post)
36
+    public function __construct( WP_Post $post )
37 37
     {
38
-        if (Application::POST_TYPE != $post->post_type) {
38
+        if( Application::POST_TYPE != $post->post_type ) {
39 39
             return;
40 40
         }
41 41
         $this->content = $post->post_content;
42 42
         $this->date = $post->post_date;
43
-        $this->ID = intval($post->ID);
43
+        $this->ID = intval( $post->ID );
44 44
         $this->status = $post->post_status;
45 45
         $this->title = $post->post_title;
46
-        $this->user_id = intval($post->post_author);
47
-        $this->setProperties($post);
48
-        $this->setTermIds($post);
46
+        $this->user_id = intval( $post->post_author );
47
+        $this->setProperties( $post );
48
+        $this->setTermIds( $post );
49 49
     }
50 50
 
51 51
     /**
52 52
      * @return mixed
53 53
      */
54
-    public function __get($key)
54
+    public function __get( $key )
55 55
     {
56
-        return $this->offsetGet($key);
56
+        return $this->offsetGet( $key );
57 57
     }
58 58
 
59 59
     /**
@@ -61,41 +61,41 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function __toString()
63 63
     {
64
-        return (string) $this->build();
64
+        return (string)$this->build();
65 65
     }
66 66
 
67 67
     /**
68 68
      * @return ReviewHtml
69 69
      */
70
-    public function build(array $args = [])
70
+    public function build( array $args = [] )
71 71
     {
72
-        if (empty($this->ID)) {
73
-            return new ReviewHtml($this);
72
+        if( empty($this->ID) ) {
73
+            return new ReviewHtml( $this );
74 74
         }
75
-        $partial = glsr(SiteReviewsPartial::class);
76
-        $partial->args = glsr(SiteReviewsDefaults::class)->merge($args);
77
-        $partial->options = Arr::flatten(glsr(OptionManager::class)->all());
78
-        return $partial->buildReview($this);
75
+        $partial = glsr( SiteReviewsPartial::class );
76
+        $partial->args = glsr( SiteReviewsDefaults::class )->merge( $args );
77
+        $partial->options = Arr::flatten( glsr( OptionManager::class )->all() );
78
+        return $partial->buildReview( $this );
79 79
     }
80 80
 
81 81
     /**
82 82
      * @param mixed $key
83 83
      * @return bool
84 84
      */
85
-    public function offsetExists($key)
85
+    public function offsetExists( $key )
86 86
     {
87
-        return property_exists($this, $key) || array_key_exists($key, (array) $this->custom);
87
+        return property_exists( $this, $key ) || array_key_exists( $key, (array)$this->custom );
88 88
     }
89 89
 
90 90
     /**
91 91
      * @param mixed $key
92 92
      * @return mixed
93 93
      */
94
-    public function offsetGet($key)
94
+    public function offsetGet( $key )
95 95
     {
96
-        return property_exists($this, $key)
96
+        return property_exists( $this, $key )
97 97
             ? $this->$key
98
-            : Arr::get($this->custom, $key, null);
98
+            : Arr::get( $this->custom, $key, null );
99 99
     }
100 100
 
101 101
     /**
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
      * @param mixed $value
104 104
      * @return void
105 105
      */
106
-    public function offsetSet($key, $value)
106
+    public function offsetSet( $key, $value )
107 107
     {
108
-        if (property_exists($this, $key)) {
108
+        if( property_exists( $this, $key ) ) {
109 109
             $this->$key = $value;
110 110
             return;
111 111
         }
112
-        if (!is_array($this->custom)) {
113
-            $this->custom = array_filter((array) $this->custom);
112
+        if( !is_array( $this->custom ) ) {
113
+            $this->custom = array_filter( (array)$this->custom );
114 114
         }
115 115
         $this->custom[$key] = $value;
116 116
     }
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
      * @param mixed $key
120 120
      * @return void
121 121
      */
122
-    public function offsetUnset($key)
122
+    public function offsetUnset( $key )
123 123
     {
124
-        $this->offsetSet($key, null);
124
+        $this->offsetSet( $key, null );
125 125
     }
126 126
 
127 127
     /**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     /**
136 136
      * @return bool
137 137
      */
138
-    protected function isModified(array $properties)
138
+    protected function isModified( array $properties )
139 139
     {
140 140
         return $this->date != $properties['date']
141 141
             || $this->content != $properties['content']
@@ -145,39 +145,39 @@  discard block
 block discarded – undo
145 145
     /**
146 146
      * @return void
147 147
      */
148
-    protected function setProperties(WP_Post $post)
148
+    protected function setProperties( WP_Post $post )
149 149
     {
150 150
         $defaults = [
151
-            'author' => __('Anonymous', 'site-reviews'),
151
+            'author' => __( 'Anonymous', 'site-reviews' ),
152 152
             'date' => '',
153 153
             'review_id' => '',
154 154
             'review_type' => 'local',
155 155
         ];
156 156
         $meta = array_filter(
157
-            array_map('array_shift', array_filter((array) get_post_meta($post->ID))),
157
+            array_map( 'array_shift', array_filter( (array)get_post_meta( $post->ID ) ) ),
158 158
             'strlen'
159 159
         );
160
-        $meta = array_merge($defaults, Arr::unprefixKeys($meta));
161
-        $properties = glsr(CreateReviewDefaults::class)->restrict(array_merge($defaults, $meta));
162
-        $this->modified = $this->isModified($properties);
163
-        array_walk($properties, function ($value, $key) {
164
-            if (!property_exists($this, $key) || isset($this->$key)) {
160
+        $meta = array_merge( $defaults, Arr::unprefixKeys( $meta ) );
161
+        $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) );
162
+        $this->modified = $this->isModified( $properties );
163
+        array_walk( $properties, function( $value, $key ) {
164
+            if( !property_exists( $this, $key ) || isset($this->$key) ) {
165 165
                 return;
166 166
             }
167
-            $this->$key = maybe_unserialize($value);
167
+            $this->$key = maybe_unserialize( $value );
168 168
         });
169 169
     }
170 170
 
171 171
     /**
172 172
      * @return void
173 173
      */
174
-    protected function setTermIds(WP_Post $post)
174
+    protected function setTermIds( WP_Post $post )
175 175
     {
176 176
         $this->term_ids = [];
177
-        if (!is_array($terms = get_the_terms($post, Application::TAXONOMY))) {
177
+        if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) ) {
178 178
             return;
179 179
         }
180
-        foreach ($terms as $term) {
180
+        foreach( $terms as $term ) {
181 181
             $this->term_ids[] = $term->term_id;
182 182
         }
183 183
     }
Please login to merge, or discard this patch.