Everywhere yoda conditions are
This commit is contained in:
@ -274,7 +274,7 @@ class Register_Endpoint {
|
||||
/*
|
||||
* Deal with status changes.
|
||||
*/
|
||||
if ($membership_status !== $membership->get_status()) {
|
||||
if ($membership->get_status() !== $membership_status) {
|
||||
$membership->set_status($membership_status);
|
||||
|
||||
$membership->save();
|
||||
@ -293,7 +293,7 @@ class Register_Endpoint {
|
||||
}
|
||||
}
|
||||
|
||||
if ($payment_status !== $payment->get_status()) {
|
||||
if ($payment->get_status() !== $payment_status) {
|
||||
$payment->set_status($payment_status);
|
||||
|
||||
$payment->save();
|
||||
@ -533,6 +533,7 @@ class Register_Endpoint {
|
||||
|
||||
return apply_filters('wu_rest_register_endpoint_args', $args, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe create a customer, if needed.
|
||||
*
|
||||
@ -675,6 +676,7 @@ class Register_Endpoint {
|
||||
'site.site_title' => 'required_with:site|min:4',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the rules and make sure we only save models when necessary.
|
||||
*
|
||||
|
@ -152,6 +152,7 @@ trait Rest_Api {
|
||||
|
||||
do_action('wu_rest_register_routes_with_id', $routes, $this->get_rest_base(), 'update', $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific item.
|
||||
*
|
||||
@ -170,6 +171,7 @@ trait Rest_Api {
|
||||
|
||||
return rest_ensure_response($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of items.
|
||||
*
|
||||
@ -184,6 +186,7 @@ trait Rest_Api {
|
||||
|
||||
return rest_ensure_response($items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an item.
|
||||
*
|
||||
@ -220,6 +223,7 @@ trait Rest_Api {
|
||||
|
||||
return rest_ensure_response($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an item.
|
||||
*
|
||||
@ -247,7 +251,7 @@ trait Rest_Api {
|
||||
foreach ($params as $param => $value) {
|
||||
$set_method = "set_{$param}";
|
||||
|
||||
if ($param === 'meta') {
|
||||
if ('meta' === $param) {
|
||||
$item->update_meta_batch($value);
|
||||
} elseif (method_exists($item, $set_method)) {
|
||||
call_user_func([$item, $set_method], $value);
|
||||
@ -279,6 +283,7 @@ trait Rest_Api {
|
||||
|
||||
return rest_ensure_response($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an item.
|
||||
*
|
||||
@ -464,7 +469,7 @@ trait Rest_Api {
|
||||
'id',
|
||||
];
|
||||
|
||||
if ($this->slug === 'site') {
|
||||
if ('site' === $this->slug) {
|
||||
$arr = [
|
||||
'id',
|
||||
'blog_id',
|
||||
@ -511,7 +516,7 @@ trait Rest_Api {
|
||||
*/
|
||||
apply_filters('wu_before_' . $this->slug . '_api_arguments', $args, $this);
|
||||
|
||||
if ($this->slug !== 'broadcast' && isset($args['author_id'])) {
|
||||
if ('broadcast' !== $this->slug && isset($args['author_id'])) {
|
||||
unset($args['author_id']);
|
||||
}
|
||||
|
||||
@ -547,15 +552,15 @@ trait Rest_Api {
|
||||
unset($args['slug']);
|
||||
}
|
||||
|
||||
if ($this->slug === 'product' && isset($args['price_variations'])) {
|
||||
if ('product' === $this->slug && isset($args['price_variations'])) {
|
||||
unset($args['price_variations']);
|
||||
}
|
||||
|
||||
if ($this->slug === 'payment' && isset($args['line_items'])) {
|
||||
if ('payment' === $this->slug && isset($args['line_items'])) {
|
||||
unset($args['line_items']);
|
||||
}
|
||||
|
||||
if ($this->slug === 'site') {
|
||||
if ('site' === $this->slug) {
|
||||
if (isset($args['duplication_arguments'])) {
|
||||
unset($args['duplication_arguments']);
|
||||
}
|
||||
@ -565,7 +570,7 @@ trait Rest_Api {
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->slug === 'email') {
|
||||
if ('email' === $this->slug) {
|
||||
if (isset($args['status'])) {
|
||||
unset($args['status']);
|
||||
}
|
||||
@ -575,7 +580,7 @@ trait Rest_Api {
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->slug === 'broadcast') {
|
||||
if ('broadcast' === $this->slug) {
|
||||
if (isset($args['message_targets'])) {
|
||||
unset($args['message_targets']);
|
||||
}
|
||||
|
@ -200,6 +200,7 @@ trait WP_CLI {
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the additional of additional parameters.
|
||||
*
|
||||
@ -283,7 +284,7 @@ trait WP_CLI {
|
||||
|
||||
$success = $item->save();
|
||||
|
||||
if ($success === true) {
|
||||
if (true === $success) {
|
||||
$item_id = $item->get_id();
|
||||
|
||||
if ( ! empty($array_assoc['porcelain'])) {
|
||||
@ -327,7 +328,7 @@ trait WP_CLI {
|
||||
foreach ($params as $param => $value) {
|
||||
$set_method = "set_{$param}";
|
||||
|
||||
if ($param === 'meta') {
|
||||
if ('meta' === $param) {
|
||||
$item->update_meta_batch($value);
|
||||
} elseif (method_exists($item, $set_method)) {
|
||||
call_user_func([$item, $set_method], $value);
|
||||
|
Reference in New Issue
Block a user