Use wp_parse_args for default args

This commit is contained in:
Jon Surrell 2016-11-13 22:14:11 +01:00
parent c418623fed
commit 4262a72af6
1 changed files with 7 additions and 6 deletions

View File

@ -46,16 +46,17 @@ abstract class WC_Log_Handler {
* Constructor for log handler. * Constructor for log handler.
* *
* @param arr $args { * @param arr $args {
* @type string $threshold Optional. Sets the log severity threshold. * @type string $threshold Optional. Default 'emergency'. Sets the log severity threshold.
* emergency|alert|critical|error|warning|notice|info|debug * emergency|alert|critical|error|warning|notice|info|debug
* } * }
*/ */
public function __construct( $args = array() ) { public function __construct( $args = array() ) {
if ( isset( $args['threshold'] ) ) {
$this->set_threshold( $args['threshold'] ); $args = wp_parse_args( $args, array(
} else { 'threshold' => WC_Logger::EMERGENCY,
$this->set_threshold( WC_Logger::EMERGENCY ); ) );
}
$this->set_threshold( $args['threshold'] );
} }
/** /**