aboutsummaryrefslogtreecommitdiff
path: root/lib.php
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2018-09-09 20:47:37 +0300
committerValentin Popov <info@valentineus.link>2018-09-09 20:47:37 +0300
commit73f45578b39f662dbc86f4c9ec43f6c60f0feee2 (patch)
treef78c020b68cfe417e2fe39ce330697fd09dec84b /lib.php
parentc18d7107b904f751ca77e4dff97b492e74a1da3c (diff)
downloadlocal_webhooks-73f45578b39f662dbc86f4c9ec43f6c60f0feee2.tar.xz
local_webhooks-73f45578b39f662dbc86f4c9ec43f6c60f0feee2.zip
Correction of checks
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'lib.php')
-rw-r--r--lib.php14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib.php b/lib.php
index 5b8b10d..9e26b26 100644
--- a/lib.php
+++ b/lib.php
@@ -44,7 +44,7 @@ class local_webhooks_api {
public static function get_service( $serviceId = 0 ) {
global $DB;
- if ( !is_numeric( $serviceId ) || empty( $serviceId ) ) {
+ if ( empty( $serviceId ) || !is_numeric( $serviceId ) ) {
print_error( "unknowparamtype", "error", null, "serviceId" );
}
@@ -94,7 +94,7 @@ class local_webhooks_api {
public static function get_services_by_event( $eventName = "" ) {
global $DB;
- if ( !is_string( $eventName ) || empty( $eventName ) ) {
+ if ( empty( $eventName ) || !is_string( $eventName ) ) {
print_error( "unknowparamtype", "error", null, "eventName" );
}
@@ -117,12 +117,12 @@ class local_webhooks_api {
public static function create_service( $service = array() ) {
global $DB;
- if ( !is_array( $service ) || empty( $service ) ) {
+ if ( empty( $service ) || !is_array( $service ) ) {
print_error( "unknowparamtype", "error", null, "service" );
}
$serviceId = $DB->insert_record( LW_TABLE_SERVICES, $service, true, false );
- if ( $serviceId && is_array( $service[ "events" ] ) && !empty( $service[ "events" ] ) ) {
+ if ( $serviceId && !empty( $service[ "events" ] ) && is_array( $service[ "events" ] ) ) {
self::insert_events( $service[ "events" ], $serviceId );
}
@@ -140,7 +140,7 @@ class local_webhooks_api {
public static function delete_service( $serviceId = 0 ) {
global $DB;
- if ( !is_numeric( $serviceId ) || empty( $serviceId ) ) {
+ if ( empty( $serviceId ) || !is_numeric( $serviceId ) ) {
print_error( "unknowparamtype", "error", null, "serviceId" );
}
@@ -159,14 +159,14 @@ class local_webhooks_api {
public static function update_service( $service = array() ) {
global $DB;
- if ( !is_array( $service ) || empty( $service ) || empty( $service[ "id" ] ) ) {
+ if ( empty( $service ) || !is_array( $service ) || empty( $service[ "id" ] ) ) {
print_error( "unknowparamtype", "error", null, "service" );
}
// TODO: Add transactions for operations
$result = $DB->update_record( LW_TABLE_SERVICES, $service, false );
$DB->delete_records( LW_TABLE_EVENTS, array( "serviceid" => $service[ "id" ] ) );
- if ( $result && is_array( $service[ "events" ] ) && !empty( $service[ "events" ] ) ) {
+ if ( $result && !empty( $service[ "events" ] ) && is_array( $service[ "events" ] ) ) {
self::insert_events( $service[ "events" ], $service[ "id" ] );
}