Passed
Push — master ( 9215df...f87ac8 )
by Paul
03:11 queued 10s
created
activate.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -59,16 +59,16 @@  discard block
 block discarded – undo
59 59
 	/**
60 60
 	 * @return bool
61 61
 	 */
62
-	public static function shouldDeactivate( $file, array $args = [] )
62
+	public static function shouldDeactivate( $file, array $args = [ ] )
63 63
 	{
64
-		if( empty( static::$instance )) {
64
+		if( empty( static::$instance ) ) {
65 65
 			static::$file = realpath( $file );
66 66
 			static::$instance = new static;
67 67
 			static::$versions = static::normalize( $args );
68 68
 		}
69 69
 		if( !static::isValid() ) {
70
-			add_action( 'activated_plugin', array( static::$instance, 'deactivate' ));
71
-			add_action( 'admin_notices', array( static::$instance, 'deactivate' ));
70
+			add_action( 'activated_plugin', array( static::$instance, 'deactivate' ) );
71
+			add_action( 'admin_notices', array( static::$instance, 'deactivate' ) );
72 72
 			return true;
73 73
 		}
74 74
 		return false;
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 		}
87 87
 		$pluginData = get_file_data( static::$file, array( 'name' => 'Plugin Name' ), 'plugin' );
88 88
 		deactivate_plugins( $pluginSlug );
89
-		$this->printNotice( $pluginData['name'] );
89
+		$this->printNotice( $pluginData[ 'name' ] );
90 90
 	}
91 91
 
92 92
 	/**
93 93
 	 * @return object
94 94
 	 */
95
-	protected static function normalize( array $args = [] )
95
+	protected static function normalize( array $args = [ ] )
96 96
 	{
97 97
 		return (object) wp_parse_args( $args, array(
98 98
 			'php' => static::MIN_PHP_VERSION,
99 99
 			'wordpress' => static::MIN_WORDPRESS_VERSION,
100
-		));
100
+		) );
101 101
 	}
102 102
 
103 103
 	/**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 			filter_input( INPUT_GET, 'plugin_status' ),
110 110
 			filter_input( INPUT_GET, 'paged' ),
111 111
 			filter_input( INPUT_GET, 's' )
112
-		)));
112
+		) ) );
113 113
 		exit;
114 114
 	}
115 115
 
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 		);
131 131
 		if( !static::isPhpValid() ) {
132 132
 			printf( $noticeTemplate,
133
-				sprintf( $messages[0], $pluginName ),
134
-				sprintf( $messages[1], $messages[3].' '.(static::$versions)->php ),
135
-				sprintf( $messages[2], PHP_VERSION )
133
+				sprintf( $messages[ 0 ], $pluginName ),
134
+				sprintf( $messages[ 1 ], $messages[ 3 ] . ' ' . ( static::$versions )->php ),
135
+				sprintf( $messages[ 2 ], PHP_VERSION )
136 136
 			);
137 137
 		}
138 138
 		else if( !static::isWpValid() ) {
139 139
 			printf( $noticeTemplate,
140
-				sprintf( $messages[0], $pluginName ),
141
-				sprintf( $messages[1], $messages[4].' '.(static::$versions)->wordpress ),
142
-				sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[5] )
140
+				sprintf( $messages[ 0 ], $pluginName ),
141
+				sprintf( $messages[ 1 ], $messages[ 4 ] . ' ' . ( static::$versions )->wordpress ),
142
+				sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages[ 5 ] )
143 143
 			);
144 144
 		}
145 145
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,9 @@
 block discarded – undo
79 79
 	 */
80 80
 	public function deactivate( $plugin )
81 81
 	{
82
-		if( static::isValid() )return;
82
+		if( static::isValid() ) {
83
+			return;
84
+		}
83 85
 		$pluginSlug = plugin_basename( static::$file );
84 86
 		if( $plugin == $pluginSlug ) {
85 87
 			$this->redirect(); //exit
Please login to merge, or discard this patch.
autoload.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 block discarded – undo
4 4
 
5 5
 spl_autoload_register( function( $className ) {
6 6
 	$namespaces = array(
7
-		'GeminiLabs\\Logger\\' => __DIR__.'/plugin/',
7
+		'GeminiLabs\\Logger\\' => __DIR__ . '/plugin/',
8 8
 	);
9 9
 	foreach( $namespaces as $prefix => $base_dir ) {
10 10
 		$len = strlen( $prefix );
11 11
 		if( strncmp( $prefix, $className, $len ) !== 0 )continue;
12
-		$file = $base_dir.str_replace( '\\', '/', substr( $className, $len )).'.php';
13
-		if( !file_exists( $file ))continue;
12
+		$file = $base_dir . str_replace( '\\', '/', substr( $className, $len ) ) . '.php';
13
+		if( !file_exists( $file ) )continue;
14 14
 		require $file;
15 15
 		break;
16 16
 	}
17 17
 });
18 18
 
19
-require_once( ABSPATH.'/wp-admin/includes/file.php' );
19
+require_once( ABSPATH . '/wp-admin/includes/file.php' );
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,15 +2,20 @@
 block discarded – undo
2 2
 
3 3
 defined( 'WPINC' ) || die;
4 4
 
5
-spl_autoload_register( function( $className ) {
5
+spl_autoload_register( function( $className )
6
+{
6 7
 	$namespaces = array(
7 8
 		'GeminiLabs\\Logger\\' => __DIR__.'/plugin/',
8 9
 	);
9 10
 	foreach( $namespaces as $prefix => $base_dir ) {
10 11
 		$len = strlen( $prefix );
11
-		if( strncmp( $prefix, $className, $len ) !== 0 )continue;
12
+		if( strncmp( $prefix, $className, $len ) !== 0 ) {
13
+			continue;
14
+		}
12 15
 		$file = $base_dir.str_replace( '\\', '/', substr( $className, $len )).'.php';
13
-		if( !file_exists( $file ))continue;
16
+		if( !file_exists( $file )) {
17
+			continue;
18
+		}
14 19
 		require $file;
15 20
 		break;
16 21
 	}
Please login to merge, or discard this patch.
plugin/Log.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @param array $context
41 41
 	 * @return static
42 42
 	 */
43
-	public function alert( $message, array $context = [] )
43
+	public function alert( $message, array $context = [ ] )
44 44
 	{
45 45
 		return $this->log( static::ALERT, $message, $context );
46 46
 	}
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 * @param array $context
62 62
 	 * @return static
63 63
 	 */
64
-	public function critical( $message, array $context = [] )
64
+	public function critical( $message, array $context = [ ] )
65 65
 	{
66 66
 		return $this->log( static::CRITICAL, $message, $context );
67 67
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param array $context
73 73
 	 * @return static
74 74
 	 */
75
-	public function debug( $message, array $context = [] )
75
+	public function debug( $message, array $context = [ ] )
76 76
 	{
77 77
 		return $this->log( static::DEBUG, $message, $context );
78 78
 	}
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param array $context
84 84
 	 * @return static
85 85
 	 */
86
-	public function emergency( $message, array $context = [] )
86
+	public function emergency( $message, array $context = [ ] )
87 87
 	{
88 88
 		return $this->log( static::EMERGENCY, $message, $context );
89 89
 	}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @param array $context
96 96
 	 * @return static
97 97
 	 */
98
-	public function error( $message, array $context = [] )
98
+	public function error( $message, array $context = [ ] )
99 99
 	{
100 100
 		return $this->log( static::ERROR, $message, $context );
101 101
 	}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @param array $context
108 108
 	 * @return static
109 109
 	 */
110
-	public function info( $message, array $context = [] )
110
+	public function info( $message, array $context = [ ] )
111 111
 	{
112 112
 		return $this->log( static::INFO, $message, $context );
113 113
 	}
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 	 * @param array $context
119 119
 	 * @return static
120 120
 	 */
121
-	public function log( $level, $message, array $context = [] )
121
+	public function log( $level, $message, array $context = [ ] )
122 122
 	{
123
-		$constants = (new ReflectionClass( __NAMESPACE__.'\Log' ))->getConstants();
124
-		$constants = (array)apply_filters( Application::ID.'/log-levels', $constants );
125
-		if( in_array( $level, $constants, true )) {
126
-			$date = get_date_from_gmt( gmdate('Y-m-d H:i:s') );
123
+		$constants = ( new ReflectionClass( __NAMESPACE__ . '\Log' ) )->getConstants();
124
+		$constants = (array) apply_filters( Application::ID . '/log-levels', $constants );
125
+		if( in_array( $level, $constants, true ) ) {
126
+			$date = get_date_from_gmt( gmdate( 'Y-m-d H:i:s' ) );
127 127
 			$level = strtoupper( $level );
128 128
 			$message = $this->interpolate( $message, $context );
129 129
 			$entry = "[$date] $level: $message" . PHP_EOL;
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @param array $context
147 147
 	 * @return static
148 148
 	 */
149
-	public function notice( $message, array $context = [] )
149
+	public function notice( $message, array $context = [ ] )
150 150
 	{
151 151
 		return $this->log( static::NOTICE, $message, $context );
152 152
 	}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * @param array $context
160 160
 	 * @return static
161 161
 	 */
162
-	public function warning( $message, array $context = [] )
162
+	public function warning( $message, array $context = [ ] )
163 163
 	{
164 164
 		return $this->log( static::WARNING, $message, $context );
165 165
 	}
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
 	 * @param array $context
170 170
 	 * @return array|string
171 171
 	 */
172
-	protected function interpolate( $message, array $context = [] )
172
+	protected function interpolate( $message, array $context = [ ] )
173 173
 	{
174
-		if( $this->isObjectOrArray( $message )) {
174
+		if( $this->isObjectOrArray( $message ) ) {
175 175
 			return print_r( $message, true );
176 176
 		}
177
-		$replace = [];
177
+		$replace = [ ];
178 178
 		foreach( $context as $key => $value ) {
179
-			$replace['{'.$key.'}'] = $this->normalizeValue( $value );
179
+			$replace[ '{' . $key . '}' ] = $this->normalizeValue( $value );
180 180
 		}
181 181
 		return strtr( $message, $replace );
182 182
 	}
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 		if( $value instanceof DateTime ) {
200 200
 			$value = $value->format( 'Y-m-d H:i:s' );
201 201
 		}
202
-		else if( $this->isObjectOrArray( $value )) {
202
+		else if( $this->isObjectOrArray( $value ) ) {
203 203
 			$value = json_encode( $value );
204 204
 		}
205
-		else if( is_resource( $value )) {
206
-			$value = (string)$value;
205
+		else if( is_resource( $value ) ) {
206
+			$value = (string) $value;
207 207
 		}
208 208
 		return $value;
209 209
 	}
Please login to merge, or discard this patch.
views/settings.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 		<input type="hidden" id="enabled" name="<?= $id; ?>[enabled]" value="<?= wp_validate_boolean( $settings->enabled ) ? 0 : 1; ?>">
21 21
 		<input type="submit" name="submit" id="submit" class="button button-primary" value="<?= wp_validate_boolean( $settings->enabled ) ? __( 'Disable Logging', 'logger' ) : __( 'Enable Logging', 'logger' ); ?>">
22 22
 	</form>
23
-	<?php if( wp_validate_boolean( $settings->enabled )) : ?>
23
+	<?php if( wp_validate_boolean( $settings->enabled ) ) : ?>
24 24
 	<br>
25 25
 	<form method="post">
26 26
 		<textarea class="large-text code" rows="20" id="log-file" onclick="this.select()" readonly><?= $log; ?></textarea>
Please login to merge, or discard this patch.
logger.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 
18 18
 defined( 'WPINC' ) || die;
19 19
 
20
-if( !class_exists( 'GL_Plugin_Check' )) {
21
-	require_once __DIR__.'/activate.php';
20
+if( !class_exists( 'GL_Plugin_Check' ) ) {
21
+	require_once __DIR__ . '/activate.php';
22 22
 }
23
-require_once __DIR__.'/autoload.php';
24
-if( GL_Plugin_Check::shouldDeactivate( __FILE__ ))return;
23
+require_once __DIR__ . '/autoload.php';
24
+if( GL_Plugin_Check::shouldDeactivate( __FILE__ ) )return;
25 25
 GeminiLabs\Logger\Application::load()->init();
26 26
 
27 27
 /**
@@ -31,6 +31,6 @@  discard block
 block discarded – undo
31 31
 function gllog( $message = null ) {
32 32
 	$logger = GeminiLabs\Logger\Application::load()->log->logger();
33 33
 	return func_num_args() > 0
34
-		? $logger->debug( func_get_arg(0) )
34
+		? $logger->debug( func_get_arg( 0 ) )
35 35
 		: $logger;
36 36
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,14 +21,17 @@
 block discarded – undo
21 21
 	require_once __DIR__.'/activate.php';
22 22
 }
23 23
 require_once __DIR__.'/autoload.php';
24
-if( GL_Plugin_Check::shouldDeactivate( __FILE__ ))return;
24
+if( GL_Plugin_Check::shouldDeactivate( __FILE__ )) {
25
+	return;
26
+}
25 27
 GeminiLabs\Logger\Application::load()->init();
26 28
 
27 29
 /**
28 30
  * @param mixed $message
29 31
  * @return GeminiLabs\Logger\Log
30 32
  */
31
-function gllog( $message = null ) {
33
+function gllog( $message = null )
34
+{
32 35
 	$logger = GeminiLabs\Logger\Application::load()->log->logger();
33 36
 	return func_num_args() > 0
34 37
 		? $logger->debug( func_get_arg(0) )
Please login to merge, or discard this patch.
plugin/Application.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public static function load()
23 23
 	{
24
-		if( empty( static::$instance )) {
24
+		if( empty( static::$instance ) ) {
25 25
 			static::$instance = new static;
26 26
 		}
27 27
 		return static::$instance;
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public function __construct()
34 34
 	{
35
-		$this->file = trailingslashit( dirname( __DIR__ )).static::ID.'.php';
36
-		$this->log = new Log( $this->path( 'development.log' ));
35
+		$this->file = trailingslashit( dirname( __DIR__ ) ) . static::ID . '.php';
36
+		$this->log = new Log( $this->path( 'development.log' ) );
37 37
 		$plugin = get_file_data( $this->file, [
38 38
 			'languages' => 'Domain Path',
39 39
 			'name' => 'Plugin Name',
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function init()
51 51
 	{
52
-		add_action( 'admin_init',     [$this, 'clearLog'] );
53
-		add_action( 'plugins_loaded', [$this, 'registerLanguages'] );
54
-		add_action( 'admin_menu',     [$this, 'registerMenu'] );
55
-		add_action( 'admin_menu',     [$this, 'registerSettings'] );
56
-		add_filter( 'all',            [$this, 'initLogger'] );
52
+		add_action( 'admin_init', [ $this, 'clearLog' ] );
53
+		add_action( 'plugins_loaded', [ $this, 'registerLanguages' ] );
54
+		add_action( 'admin_menu', [ $this, 'registerMenu' ] );
55
+		add_action( 'admin_menu', [ $this, 'registerSettings' ] );
56
+		add_filter( 'all', [ $this, 'initLogger' ] );
57 57
 	}
58 58
 
59 59
 	/**
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function initLogger()
64 64
 	{
65
-		$args = func_get_args() + ['', null, 'debug'];
66
-		if( $args[0] !== static::ID || is_null( $args[1] ))return;
67
-		$this->log->log( $args[2], $args[1] );
65
+		$args = func_get_args() + [ '', null, 'debug' ];
66
+		if( $args[ 0 ] !== static::ID || is_null( $args[ 1 ] ) )return;
67
+		$this->log->log( $args[ 2 ], $args[ 1 ] );
68 68
 	}
69 69
 
70 70
 	/**
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function clearLog()
74 74
 	{
75
-		$request = filter_input( INPUT_POST, static::ID, FILTER_DEFAULT , FILTER_REQUIRE_ARRAY );
76
-		if( empty( $request['action'] ) || $request['action'] != 'clear-log' )return;
77
-		check_admin_referer( $request['action'] );
75
+		$request = filter_input( INPUT_POST, static::ID, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
76
+		if( empty( $request[ 'action' ] ) || $request[ 'action' ] != 'clear-log' )return;
77
+		check_admin_referer( $request[ 'action' ] );
78 78
 		$this->log->clear();
79
-		add_action( 'admin_notices', [$this, 'renderNotice'] );
79
+		add_action( 'admin_notices', [ $this, 'renderNotice' ] );
80 80
 	}
81 81
 
82 82
 	/**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function path( $file = '' )
87 87
 	{
88
-		return realpath( plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' ));
88
+		return realpath( plugin_dir_path( $this->file ) . ltrim( trim( $file ), '/' ) );
89 89
 	}
90 90
 
91 91
 	/**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	public function registerLanguages()
95 95
 	{
96 96
 		load_plugin_textdomain( static::ID, '',
97
-			trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages )
97
+			trailingslashit( plugin_basename( $this->path() ) . '/' . $this->languages )
98 98
 		);
99 99
 	}
100 100
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 			__( 'Logger', 'logger' ),
111 111
 			'manage_options',
112 112
 			static::ID,
113
-			[$this, 'renderSettingsPage']
113
+			[ $this, 'renderSettingsPage' ]
114 114
 		);
115 115
 	}
116 116
 
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 	 * @param string $view
128 128
 	 * @return void|null
129 129
 	 */
130
-	public function render( $view, array $data = [] )
130
+	public function render( $view, array $data = [ ] )
131 131
 	{
132
-		if( !file_exists( $file = $this->path( 'views/'.$view.'.php' )))return;
132
+		if( !file_exists( $file = $this->path( 'views/' . $view . '.php' ) ) )return;
133 133
 		extract( $data );
134 134
 		include $file;
135 135
 	}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		$this->render( 'notice', [
143 143
 			'notice' => __( 'The log was cleared.', 'logger' ),
144 144
 			'status' => 'success',
145
-		]);
145
+		] );
146 146
 	}
147 147
 
148 148
 	/**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			'log' => $this->log,
157 157
 			'settings' => $this->getSettings(),
158 158
 			'title' => __( 'Logger', 'logger' ),
159
-		]);
159
+		] );
160 160
 	}
161 161
 
162 162
 	/**
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	protected function getSettings()
166 166
 	{
167
-		$settings = get_option( static::ID, [] );
168
-		if( empty( $settings )) {
167
+		$settings = get_option( static::ID, [ ] );
168
+		if( empty( $settings ) ) {
169 169
 			update_option( static::ID, $settings = [
170 170
 				'enabled' => 0,
171
-			]);
171
+			] );
172 172
 		}
173
-		return (object)$settings;
173
+		return (object) $settings;
174 174
 	}
175 175
 }
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,7 +39,8 @@  discard block
 block discarded – undo
39 39
 			'name' => 'Plugin Name',
40 40
 			'version' => 'Version',
41 41
 		], 'plugin' );
42
-		array_walk( $plugin, function( $value, $key ) {
42
+		array_walk( $plugin, function( $value, $key )
43
+		{
43 44
 			$this->$key = $value;
44 45
 		});
45 46
 	}
@@ -63,7 +64,9 @@  discard block
 block discarded – undo
63 64
 	public function initLogger()
64 65
 	{
65 66
 		$args = func_get_args() + ['', null, 'debug'];
66
-		if( $args[0] !== static::ID || is_null( $args[1] ))return;
67
+		if( $args[0] !== static::ID || is_null( $args[1] )) {
68
+			return;
69
+		}
67 70
 		$this->log->log( $args[2], $args[1] );
68 71
 	}
69 72
 
@@ -73,7 +76,9 @@  discard block
 block discarded – undo
73 76
 	public function clearLog()
74 77
 	{
75 78
 		$request = filter_input( INPUT_POST, static::ID, FILTER_DEFAULT , FILTER_REQUIRE_ARRAY );
76
-		if( empty( $request['action'] ) || $request['action'] != 'clear-log' )return;
79
+		if( empty( $request['action'] ) || $request['action'] != 'clear-log' ) {
80
+			return;
81
+		}
77 82
 		check_admin_referer( $request['action'] );
78 83
 		$this->log->clear();
79 84
 		add_action( 'admin_notices', [$this, 'renderNotice'] );
@@ -129,7 +134,9 @@  discard block
 block discarded – undo
129 134
 	 */
130 135
 	public function render( $view, array $data = [] )
131 136
 	{
132
-		if( !file_exists( $file = $this->path( 'views/'.$view.'.php' )))return;
137
+		if( !file_exists( $file = $this->path( 'views/'.$view.'.php' ))) {
138
+			return;
139
+		}
133 140
 		extract( $data );
134 141
 		include $file;
135 142
 	}
Please login to merge, or discard this patch.