From 76a9e194712257202c93da29dbc207be6947d28e Mon Sep 17 00:00:00 2001 From: Khan M Rashedun-Naby Date: Thu, 7 Jun 2018 13:46:06 +0600 Subject: [PATCH] wc_get_logger refactored --- includes/wc-core-functions.php | 46 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 66641367ac9..9258194ae71 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -1636,30 +1636,30 @@ function wc_get_logger() { $class = apply_filters( 'woocommerce_logging_class', 'WC_Logger' ); - if ( null === $logger || ! is_a( $logger, $class ) ) { - $implements = class_implements( $class ); - - if ( is_array( $implements ) && in_array( 'WC_Logger_Interface', $implements, true ) ) { - if ( is_object( $class ) ) { - $logger = $class; - } else { - $logger = new $class(); - } - } else { - wc_doing_it_wrong( - __FUNCTION__, - sprintf( - /* translators: 1: class name 2: woocommerce_logging_class 3: WC_Logger_Interface */ - __( 'The class %1$s provided by %2$s filter must implement %3$s.', 'woocommerce' ), - '' . esc_html( is_object( $class ) ? get_class( $class ) : $class ) . '', - 'woocommerce_logging_class', - 'WC_Logger_Interface' - ), - '3.0' - ); - $logger = is_a( $logger, 'WC_Logger' ) ? $logger : new WC_Logger(); - } + if ( null !== $logger && is_a( $logger, $class ) ) { + return $logger; } + + $implements = class_implements( $class ); + + if ( is_array( $implements ) && in_array( 'WC_Logger_Interface', $implements, true ) ) { + $logger = is_object( $class ) ? $class : new $class(); + } else { + wc_doing_it_wrong( + __FUNCTION__, + sprintf( + /* translators: 1: class name 2: woocommerce_logging_class 3: WC_Logger_Interface */ + __( 'The class %1$s provided by %2$s filter must implement %3$s.', 'woocommerce' ), + '' . esc_html( is_object( $class ) ? get_class( $class ) : $class ) . '', + 'woocommerce_logging_class', + 'WC_Logger_Interface' + ), + '3.0' + ); + + $logger = is_a( $logger, 'WC_Logger' ) ? $logger : new WC_Logger(); + } + return $logger; }