@@ -59,16 +59,16 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -79,7 +79,9 @@ |
||
| 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 |
@@ -21,7 +21,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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,11 +62,11 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function initLogger() |
| 64 | 64 | { |
| 65 | - if( func_get_arg(0) != static::ID )return; |
|
| 66 | - $type = func_get_arg(2) |
|
| 67 | - ? func_get_arg(2) |
|
| 65 | + if( func_get_arg( 0 ) != static::ID )return; |
|
| 66 | + $type = func_get_arg( 2 ) |
|
| 67 | + ? func_get_arg( 2 ) |
|
| 68 | 68 | : 'debug'; |
| 69 | - $this->log->log( $type, func_get_arg(1) ); |
|
| 69 | + $this->log->log( $type, func_get_arg( 1 ) ); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function clearLog() |
| 76 | 76 | { |
| 77 | - $request = filter_input( INPUT_POST, static::ID, FILTER_DEFAULT , FILTER_REQUIRE_ARRAY ); |
|
| 78 | - if( empty( $request['action'] ) || $request['action'] != 'clear-log' )return; |
|
| 79 | - check_admin_referer( $request['action'] ); |
|
| 77 | + $request = filter_input( INPUT_POST, static::ID, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
| 78 | + if( empty( $request[ 'action' ] ) || $request[ 'action' ] != 'clear-log' )return; |
|
| 79 | + check_admin_referer( $request[ 'action' ] ); |
|
| 80 | 80 | $this->log->clear(); |
| 81 | - add_action( 'admin_notices', [$this, 'renderNotice'] ); |
|
| 81 | + add_action( 'admin_notices', [ $this, 'renderNotice' ] ); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function path( $file = '' ) |
| 89 | 89 | { |
| 90 | - return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' ); |
|
| 90 | + return plugin_dir_path( $this->file ) . ltrim( trim( $file ), '/' ); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | public function registerLanguages() |
| 97 | 97 | { |
| 98 | 98 | load_plugin_textdomain( static::ID, false, |
| 99 | - trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages ) |
|
| 99 | + trailingslashit( plugin_basename( $this->path() ) . '/' . $this->languages ) |
|
| 100 | 100 | ); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | __( 'Logger', 'logger' ), |
| 113 | 113 | 'manage_options', |
| 114 | 114 | static::ID, |
| 115 | - [$this, 'renderSettingsPage'] |
|
| 115 | + [ $this, 'renderSettingsPage' ] |
|
| 116 | 116 | ); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | * @param string $view |
| 130 | 130 | * @return void|null |
| 131 | 131 | */ |
| 132 | - public function render( $view, array $data = [] ) |
|
| 132 | + public function render( $view, array $data = [ ] ) |
|
| 133 | 133 | { |
| 134 | - if( !file_exists( $file = $this->path( 'views/'.$view.'.php' )))return; |
|
| 134 | + if( !file_exists( $file = $this->path( 'views/' . $view . '.php' ) ) )return; |
|
| 135 | 135 | extract( $data ); |
| 136 | 136 | include $file; |
| 137 | 137 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $this->render( 'notice', [ |
| 145 | 145 | 'notice' => __( 'The log was cleared.', 'logger' ), |
| 146 | 146 | 'status' => 'success', |
| 147 | - ]); |
|
| 147 | + ] ); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | 'log' => $this->log, |
| 159 | 159 | 'settings' => $this->getSettings(), |
| 160 | 160 | 'title' => __( 'Logger', 'logger' ), |
| 161 | - ]); |
|
| 161 | + ] ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -166,12 +166,12 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | protected function getSettings() |
| 168 | 168 | { |
| 169 | - $settings = get_option( static::ID, [] ); |
|
| 170 | - if( empty( $settings )) { |
|
| 169 | + $settings = get_option( static::ID, [ ] ); |
|
| 170 | + if( empty( $settings ) ) { |
|
| 171 | 171 | update_option( static::ID, $settings = [ |
| 172 | 172 | 'enabled' => 0, |
| 173 | - ]); |
|
| 173 | + ] ); |
|
| 174 | 174 | } |
| 175 | - return (object)$settings; |
|
| 175 | + return (object) $settings; |
|
| 176 | 176 | } |
| 177 | 177 | } |
@@ -39,7 +39,8 @@ discard block |
||
| 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 | } |
@@ -62,7 +63,9 @@ discard block |
||
| 62 | 63 | */ |
| 63 | 64 | public function initLogger() |
| 64 | 65 | { |
| 65 | - if( func_get_arg(0) != static::ID )return; |
|
| 66 | + if( func_get_arg(0) != static::ID ) { |
|
| 67 | + return; |
|
| 68 | + } |
|
| 66 | 69 | $type = func_get_arg(2) |
| 67 | 70 | ? func_get_arg(2) |
| 68 | 71 | : 'debug'; |
@@ -75,7 +78,9 @@ discard block |
||
| 75 | 78 | public function clearLog() |
| 76 | 79 | { |
| 77 | 80 | $request = filter_input( INPUT_POST, static::ID, FILTER_DEFAULT , FILTER_REQUIRE_ARRAY ); |
| 78 | - if( empty( $request['action'] ) || $request['action'] != 'clear-log' )return; |
|
| 81 | + if( empty( $request['action'] ) || $request['action'] != 'clear-log' ) { |
|
| 82 | + return; |
|
| 83 | + } |
|
| 79 | 84 | check_admin_referer( $request['action'] ); |
| 80 | 85 | $this->log->clear(); |
| 81 | 86 | add_action( 'admin_notices', [$this, 'renderNotice'] ); |
@@ -131,7 +136,9 @@ discard block |
||
| 131 | 136 | */ |
| 132 | 137 | public function render( $view, array $data = [] ) |
| 133 | 138 | { |
| 134 | - if( !file_exists( $file = $this->path( 'views/'.$view.'.php' )))return; |
|
| 139 | + if( !file_exists( $file = $this->path( 'views/'.$view.'.php' ))) { |
|
| 140 | + return; |
|
| 141 | + } |
|
| 135 | 142 | extract( $data ); |
| 136 | 143 | include $file; |
| 137 | 144 | } |
@@ -4,16 +4,16 @@ |
||
| 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' ); |
|
@@ -2,15 +2,20 @@ |
||
| 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 | } |
@@ -20,7 +20,7 @@ |
||
| 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" class="float-left"> |
| 26 | 26 | <textarea class="large-text code" rows="20" id="log-file" onclick="this.select()" readonly><?= $log; ?></textarea> |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | defined( 'WPINC' ) || die; |
| 19 | 19 | |
| 20 | -if( !class_exists( 'GL_Activate' )) { |
|
| 21 | - require_once __DIR__.'/activate.php'; |
|
| 20 | +if( !class_exists( 'GL_Activate' ) ) { |
|
| 21 | + require_once __DIR__ . '/activate.php'; |
|
| 22 | 22 | } |
| 23 | -require_once __DIR__.'/autoload.php'; |
|
| 24 | -if( GL_Activate::shouldDeactivate( __FILE__ ))return; |
|
| 23 | +require_once __DIR__ . '/autoload.php'; |
|
| 24 | +if( GL_Activate::shouldDeactivate( __FILE__ ) )return; |
|
| 25 | 25 | GeminiLabs\Logger\Application::load()->init(); |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -32,6 +32,6 @@ discard block |
||
| 32 | 32 | function gllog( $message = null ) { |
| 33 | 33 | $logger = GeminiLabs\Logger\Application::load()->log->logger(); |
| 34 | 34 | return func_num_args() > 0 |
| 35 | - ? $logger->debug( func_get_arg(0) ) |
|
| 35 | + ? $logger->debug( func_get_arg( 0 ) ) |
|
| 36 | 36 | : $logger; |
| 37 | 37 | } |
@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | require_once __DIR__.'/activate.php'; |
| 22 | 22 | } |
| 23 | 23 | require_once __DIR__.'/autoload.php'; |
| 24 | -if( GL_Activate::shouldDeactivate( __FILE__ ))return; |
|
| 24 | +if( GL_Activate::shouldDeactivate( __FILE__ )) { |
|
| 25 | + return; |
|
| 26 | +} |
|
| 25 | 27 | GeminiLabs\Logger\Application::load()->init(); |
| 26 | 28 | |
| 27 | 29 | /** |
@@ -29,7 +31,8 @@ discard block |
||
| 29 | 31 | * @param mixed $message |
| 30 | 32 | * @return GeminiLabs\Logger\Log |
| 31 | 33 | */ |
| 32 | -function gllog( $message = null ) { |
|
| 34 | +function gllog( $message = null ) |
|
| 35 | +{ |
|
| 33 | 36 | $logger = GeminiLabs\Logger\Application::load()->log->logger(); |
| 34 | 37 | return func_num_args() > 0 |
| 35 | 38 | ? $logger->debug( func_get_arg(0) ) |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param array $context |
| 40 | 40 | * @return static |
| 41 | 41 | */ |
| 42 | - public function alert( $message, array $context = [] ) |
|
| 42 | + public function alert( $message, array $context = [ ] ) |
|
| 43 | 43 | { |
| 44 | 44 | return $this->log( static::ALERT, $message, $context ); |
| 45 | 45 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param array $context |
| 61 | 61 | * @return static |
| 62 | 62 | */ |
| 63 | - public function critical( $message, array $context = [] ) |
|
| 63 | + public function critical( $message, array $context = [ ] ) |
|
| 64 | 64 | { |
| 65 | 65 | return $this->log( static::CRITICAL, $message, $context ); |
| 66 | 66 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @param array $context |
| 72 | 72 | * @return static |
| 73 | 73 | */ |
| 74 | - public function debug( $message, array $context = [] ) |
|
| 74 | + public function debug( $message, array $context = [ ] ) |
|
| 75 | 75 | { |
| 76 | 76 | return $this->log( static::DEBUG, $message, $context ); |
| 77 | 77 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param array $context |
| 83 | 83 | * @return static |
| 84 | 84 | */ |
| 85 | - public function emergency( $message, array $context = [] ) |
|
| 85 | + public function emergency( $message, array $context = [ ] ) |
|
| 86 | 86 | { |
| 87 | 87 | return $this->log( static::EMERGENCY, $message, $context ); |
| 88 | 88 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @param array $context |
| 95 | 95 | * @return static |
| 96 | 96 | */ |
| 97 | - public function error( $message, array $context = [] ) |
|
| 97 | + public function error( $message, array $context = [ ] ) |
|
| 98 | 98 | { |
| 99 | 99 | return $this->log( static::ERROR, $message, $context ); |
| 100 | 100 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param array $context |
| 107 | 107 | * @return static |
| 108 | 108 | */ |
| 109 | - public function info( $message, array $context = [] ) |
|
| 109 | + public function info( $message, array $context = [ ] ) |
|
| 110 | 110 | { |
| 111 | 111 | return $this->log( static::INFO, $message, $context ); |
| 112 | 112 | } |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | * @param array $context |
| 118 | 118 | * @return static |
| 119 | 119 | */ |
| 120 | - public function log( $level, $message, array $context = [] ) |
|
| 120 | + public function log( $level, $message, array $context = [ ] ) |
|
| 121 | 121 | { |
| 122 | - $constants = (new ReflectionClass( __NAMESPACE__.'\Log' ))->getConstants(); |
|
| 123 | - $constants = (array)apply_filters( Application::ID.'/log-levels', $constants ); |
|
| 124 | - if( in_array( $level, $constants, true )) { |
|
| 125 | - $date = get_date_from_gmt( gmdate('Y-m-d H:i:s') ); |
|
| 122 | + $constants = ( new ReflectionClass( __NAMESPACE__ . '\Log' ) )->getConstants(); |
|
| 123 | + $constants = (array) apply_filters( Application::ID . '/log-levels', $constants ); |
|
| 124 | + if( in_array( $level, $constants, true ) ) { |
|
| 125 | + $date = get_date_from_gmt( gmdate( 'Y-m-d H:i:s' ) ); |
|
| 126 | 126 | $level = strtoupper( $level ); |
| 127 | 127 | $message = $this->interpolate( $message, $context ); |
| 128 | 128 | $entry = "[$date] $level: $message" . PHP_EOL; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param array $context |
| 146 | 146 | * @return static |
| 147 | 147 | */ |
| 148 | - public function notice( $message, array $context = [] ) |
|
| 148 | + public function notice( $message, array $context = [ ] ) |
|
| 149 | 149 | { |
| 150 | 150 | return $this->log( static::NOTICE, $message, $context ); |
| 151 | 151 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param array $context |
| 159 | 159 | * @return static |
| 160 | 160 | */ |
| 161 | - public function warning( $message, array $context = [] ) |
|
| 161 | + public function warning( $message, array $context = [ ] ) |
|
| 162 | 162 | { |
| 163 | 163 | return $this->log( static::WARNING, $message, $context ); |
| 164 | 164 | } |
@@ -168,23 +168,23 @@ discard block |
||
| 168 | 168 | * @param array $context |
| 169 | 169 | * @return array|string |
| 170 | 170 | */ |
| 171 | - protected function interpolate( $message, array $context = [] ) |
|
| 171 | + protected function interpolate( $message, array $context = [ ] ) |
|
| 172 | 172 | { |
| 173 | - if( is_array( $message ) || is_object( $message )) { |
|
| 173 | + if( is_array( $message ) || is_object( $message ) ) { |
|
| 174 | 174 | return print_r( $message, true ); |
| 175 | 175 | } |
| 176 | - $replace = []; |
|
| 176 | + $replace = [ ]; |
|
| 177 | 177 | foreach( $context as $key => $val ) { |
| 178 | 178 | if( is_object( $val ) && get_class( $val ) === 'DateTime' ) { |
| 179 | 179 | $val = $val->format( 'Y-m-d H:i:s' ); |
| 180 | 180 | } |
| 181 | - else if( is_object( $val ) || is_array( $val )) { |
|
| 181 | + else if( is_object( $val ) || is_array( $val ) ) { |
|
| 182 | 182 | $val = json_encode( $val ); |
| 183 | 183 | } |
| 184 | - else if( is_resource( $val )) { |
|
| 184 | + else if( is_resource( $val ) ) { |
|
| 185 | 185 | $val = (string) $val; |
| 186 | 186 | } |
| 187 | - $replace['{'.$key.'}'] = $val; |
|
| 187 | + $replace[ '{' . $key . '}' ] = $val; |
|
| 188 | 188 | } |
| 189 | 189 | return strtr( $message, $replace ); |
| 190 | 190 | } |