From afe8c1151fa93dccad08111d00d8c986dc3e6f1d Mon Sep 17 00:00:00 2001 From: Alex Standiford Date: Mon, 21 Jun 2021 20:41:15 -0600 Subject: [PATCH] Replace filter call with find call. #1 (#2) (#3) --- lib/abstracts/Event_Type.php | 2 +- lib/abstracts/Writer.php | 2 +- lib/abstracts/registries/Event_Registry.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/abstracts/Event_Type.php b/lib/abstracts/Event_Type.php index ae92035..c9a70d0 100644 --- a/lib/abstracts/Event_Type.php +++ b/lib/abstracts/Event_Type.php @@ -331,7 +331,7 @@ public function __get( $key ) { if ( isset( $this->$key ) ) { return $this->$key; } else { - return new WP_error( 'logger_param_not_set', 'The logger param ' . $key . ' could not be found.' ); + return new WP_Error( 'logger_param_not_set', 'The logger param ' . $key . ' could not be found.' ); } } diff --git a/lib/abstracts/Writer.php b/lib/abstracts/Writer.php index 09f432d..6b0bc0f 100644 --- a/lib/abstracts/Writer.php +++ b/lib/abstracts/Writer.php @@ -90,7 +90,7 @@ public function __get( $key ) { if ( isset( $this->$key ) ) { return $this->$key; } else { - return new WP_error( 'batch_task_param_not_set', 'The batch task key ' . $key . ' could not be found.' ); + return new WP_Error( 'batch_task_param_not_set', 'The batch task key ' . $key . ' could not be found.' ); } } } \ No newline at end of file diff --git a/lib/abstracts/registries/Event_Registry.php b/lib/abstracts/registries/Event_Registry.php index 2edb23f..6c25f15 100644 --- a/lib/abstracts/registries/Event_Registry.php +++ b/lib/abstracts/registries/Event_Registry.php @@ -232,17 +232,17 @@ public function get( $key ) { // If the logged event could not be found, search event type keys. if ( is_wp_error( $result ) ) { - $event_types = $this->filter( [ + $event_type = $this->find( [ 'type' => $key, ] ); // If that also comes up empty, return the error. - if ( empty( $event_types ) ) { + if ( is_wp_error( $event_type ) ) { return $result; } // Return the discovered event. - $result = $event_types[0]; + $result = $event_type; } return $result;