From 36ddf415c40aee485e432be6925d14e71690fc39 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 20 Sep 2018 18:05:02 +0400 Subject: Reducing nesting in the code Signed-off-by: Valentin Popov --- classes/task/process_events_task.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/classes/task/process_events_task.php b/classes/task/process_events_task.php index d2d1ca9..84b5c88 100644 --- a/classes/task/process_events_task.php +++ b/classes/task/process_events_task.php @@ -45,18 +45,20 @@ class process_events_task extends \core\task\adhoc_task { $services = \local_webhooks_api::get_services_by_event( $this->get_custom_data()->eventname ); foreach ( $services as $service ) { - if ( !empty( $service->status ) ) { - $curl = new \curl(); + if ( empty( $service->status ) ) { + return; + } - $event = (array) $this->get_custom_data(); - $event[ "token" ] = $service->token; + $curl = new \curl(); - $curl->setHeader( array( "Content-Type: " . $service->header ) ); - $curl->post( $service->point, json_encode( $event ) ); + $event = (array) $this->get_custom_data(); + $event[ "token" ] = $service->token; - // TODO: Mark the log - $curl->getResponse(); - } + $curl->setHeader( array( "Content-Type: " . $service->header ) ); + $curl->post( $service->point, json_encode( $event ) ); + + // TODO: Mark the log + $curl->getResponse(); } } } \ No newline at end of file -- cgit v1.2.3