Skip to content

Commit

Permalink
refactored code to use IF instead of SWITCH
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijitb committed Feb 8, 2023
1 parent 43ebccd commit 9068f59
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions includes/RestApi/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,14 @@ public function get_current_settings() {
$filtered_social_urls = array();
// handle other social urls for onboarding
foreach ( $social_data['other_social_urls'] as $index => $social_url ) {
switch ( $social_url ) {
case ( preg_match( '/(?:https?:\/\/)?(www\.)?yelp\.com/', $social_url ) ? true : false ):
if ( ! empty( $social_url ) ) {
if ( preg_match( '/(?:https?:\/\/)?(www\.)?yelp\.com/', $social_url ) ) {
$filtered_social_urls['yelp_url'] = $social_url;
break;
case ( preg_match( '/(?:https?:\/\/)?(www\.)?tiktok\.com/', $social_url ) ? true : false ):
} elseif ( preg_match( '/(?:https?:\/\/)?(www\.)?tiktok\.com/', $social_url ) ) {
$filtered_social_urls['tiktok_url'] = $social_url;
break;
default:
// creating key value pairs for other social urls instead of indexed array
} else {
$filtered_social_urls[ 'social_url_' . $index ] = $social_url;
break;
}
}
}
$social_data['other_social_urls'] = $filtered_social_urls;
Expand Down

0 comments on commit 9068f59

Please sign in to comment.