More yoda conditions
This commit is contained in:
@ -240,7 +240,7 @@ abstract class Base_Model implements \JsonSerializable {
|
||||
/*
|
||||
* Keeps the original.
|
||||
*/
|
||||
if ($this->_original === null) {
|
||||
if (null === $this->_original) {
|
||||
$original = get_object_vars($this);
|
||||
|
||||
unset($original['_original']);
|
||||
|
@ -125,7 +125,7 @@ class Broadcast extends Post_Base_Model {
|
||||
*/
|
||||
public function get_migrated_from_id() {
|
||||
|
||||
if ($this->migrated_from_id === null) {
|
||||
if (null === $this->migrated_from_id) {
|
||||
$this->migrated_from_id = $this->get_meta('migrated_from_id', 0);
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ class Broadcast extends Post_Base_Model {
|
||||
*/
|
||||
public function get_notice_type() {
|
||||
|
||||
if ($this->notice_type === null) {
|
||||
if (null === $this->notice_type) {
|
||||
$this->notice_type = $this->get_meta('notice_type', 'success');
|
||||
}
|
||||
|
||||
|
@ -1089,7 +1089,7 @@ class Checkout_Form extends Base_Model {
|
||||
*/
|
||||
public function get_thank_you_page_id() {
|
||||
|
||||
if ($this->thank_you_page_id === null) {
|
||||
if (null === $this->thank_you_page_id) {
|
||||
$this->thank_you_page_id = $this->get_meta('wu_thank_you_page_id', '');
|
||||
}
|
||||
|
||||
@ -1118,7 +1118,7 @@ class Checkout_Form extends Base_Model {
|
||||
*/
|
||||
public function get_conversion_snippets() {
|
||||
|
||||
if ($this->conversion_snippets === null) {
|
||||
if (null === $this->conversion_snippets) {
|
||||
$this->conversion_snippets = $this->get_meta('wu_conversion_snippets', '');
|
||||
}
|
||||
|
||||
|
@ -547,7 +547,7 @@ class Customer extends Base_Model {
|
||||
*/
|
||||
public function get_extra_information() {
|
||||
|
||||
if ($this->extra_information === null) {
|
||||
if (null === $this->extra_information) {
|
||||
$extra_information = (array) $this->get_meta('wu_customer_extra_information');
|
||||
|
||||
$this->extra_information = array_filter($extra_information);
|
||||
|
@ -709,7 +709,7 @@ class Discount_Code extends Base_Model {
|
||||
*/
|
||||
public function get_allowed_products() {
|
||||
|
||||
if ($this->allowed_products === null) {
|
||||
if (null === $this->allowed_products) {
|
||||
$this->allowed_products = $this->get_meta('wu_allowed_products', []);
|
||||
}
|
||||
|
||||
@ -738,7 +738,7 @@ class Discount_Code extends Base_Model {
|
||||
*/
|
||||
public function get_limit_products() {
|
||||
|
||||
if ($this->limit_products === null) {
|
||||
if (null === $this->limit_products) {
|
||||
$this->limit_products = $this->get_meta('wu_limit_products', false);
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ class Email extends Post_Base_Model {
|
||||
*/
|
||||
public function get_event() {
|
||||
|
||||
if ($this->event === null) {
|
||||
if (null === $this->event) {
|
||||
$this->event = $this->get_meta('wu_system_email_event');
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ class Email extends Post_Base_Model {
|
||||
|
||||
$this->style = $this->get_meta('wu_style', 'html');
|
||||
|
||||
if ($this->style === 'use_default') {
|
||||
if ('use_default' === $this->style) {
|
||||
$this->style = wu_get_setting('email_template_type', 'html');
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ class Email extends Post_Base_Model {
|
||||
*/
|
||||
public function has_schedule() {
|
||||
|
||||
if ($this->schedule === null) {
|
||||
if (null === $this->schedule) {
|
||||
$this->schedule = $this->get_meta('wu_schedule', false);
|
||||
}
|
||||
|
||||
@ -532,7 +532,7 @@ class Email extends Post_Base_Model {
|
||||
*/
|
||||
public function get_target() {
|
||||
|
||||
if ($this->target === null) {
|
||||
if (null === $this->target) {
|
||||
$this->target = $this->get_meta('wu_target', 'admin');
|
||||
}
|
||||
|
||||
@ -633,7 +633,7 @@ class Email extends Post_Base_Model {
|
||||
*/
|
||||
public function get_send_copy_to_admin() {
|
||||
|
||||
if ($this->send_copy_to_admin === null) {
|
||||
if (null === $this->send_copy_to_admin) {
|
||||
$this->send_copy_to_admin = $this->get_meta('wu_send_copy_to_admin', false);
|
||||
}
|
||||
|
||||
@ -662,7 +662,7 @@ class Email extends Post_Base_Model {
|
||||
*/
|
||||
public function is_active() {
|
||||
|
||||
if ($this->active === null) {
|
||||
if (null === $this->active) {
|
||||
$this->active = $this->get_meta('wu_active', true);
|
||||
}
|
||||
|
||||
@ -691,7 +691,7 @@ class Email extends Post_Base_Model {
|
||||
*/
|
||||
public function is_legacy() {
|
||||
|
||||
if ($this->legacy === null) {
|
||||
if (null === $this->legacy) {
|
||||
$this->legacy = $this->get_meta('wu_legacy', false);
|
||||
}
|
||||
|
||||
|
@ -482,7 +482,7 @@ class Membership extends Base_Model {
|
||||
if ($plan && ($plan->get_duration() !== $this->get_duration() || $plan->get_duration_unit() !== $this->get_duration_unit())) {
|
||||
$variation = $plan->get_as_variation($this->get_duration(), $this->get_duration_unit());
|
||||
|
||||
$plan = ($variation ? $variation : null) ?? $plan;
|
||||
$plan = ($variation ?: null) ?? $plan;
|
||||
}
|
||||
|
||||
return $plan;
|
||||
@ -1342,7 +1342,7 @@ class Membership extends Base_Model {
|
||||
*/
|
||||
public function get_discount_code() {
|
||||
|
||||
if ($this->discount_code === null) {
|
||||
if (null === $this->discount_code) {
|
||||
$this->discount_code = $this->get_meta('discount_code');
|
||||
}
|
||||
|
||||
|
@ -597,7 +597,7 @@ class Payment extends Base_Model {
|
||||
*/
|
||||
public function get_line_items(): array {
|
||||
|
||||
if ($this->line_items === null) {
|
||||
if (null === $this->line_items) {
|
||||
$line_items = (array) $this->get_meta('wu_line_items');
|
||||
|
||||
$this->line_items = array_filter($line_items);
|
||||
@ -877,7 +877,7 @@ class Payment extends Base_Model {
|
||||
*/
|
||||
public function get_saved_invoice_number() {
|
||||
|
||||
if ($this->invoice_number === null) {
|
||||
if (null === $this->invoice_number) {
|
||||
$this->invoice_number = $this->get_meta('wu_invoice_number', '');
|
||||
}
|
||||
|
||||
@ -898,11 +898,11 @@ class Payment extends Base_Model {
|
||||
|
||||
$provisional = false;
|
||||
|
||||
if ($this->invoice_number === null) {
|
||||
if (null === $this->invoice_number) {
|
||||
$this->invoice_number = $this->get_meta('wu_invoice_number');
|
||||
}
|
||||
|
||||
if ($this->invoice_number === false) {
|
||||
if (false === $this->invoice_number) {
|
||||
$provisional = true;
|
||||
|
||||
$this->invoice_number = wu_get_setting('next_invoice_number');
|
||||
@ -981,7 +981,7 @@ class Payment extends Base_Model {
|
||||
*/
|
||||
public function should_cancel_membership_on_refund() {
|
||||
|
||||
if ($this->cancel_membership_on_refund === null) {
|
||||
if (null === $this->cancel_membership_on_refund) {
|
||||
$this->cancel_membership_on_refund = $this->get_meta('wu_cancel_membership_on_refund', false);
|
||||
}
|
||||
|
||||
|
@ -334,7 +334,7 @@ class Product extends Base_Model {
|
||||
*/
|
||||
public function get_featured_image_id() {
|
||||
|
||||
if ($this->featured_image_id === null) {
|
||||
if (null === $this->featured_image_id) {
|
||||
$this->featured_image_id = $this->get_meta('wu_featured_image_id');
|
||||
}
|
||||
|
||||
@ -1055,7 +1055,7 @@ class Product extends Base_Model {
|
||||
*/
|
||||
public function get_tax_category() {
|
||||
|
||||
if ($this->tax_category === null) {
|
||||
if (null === $this->tax_category) {
|
||||
$this->tax_category = $this->get_meta('tax_category', 'default');
|
||||
}
|
||||
|
||||
@ -1085,7 +1085,7 @@ class Product extends Base_Model {
|
||||
*/
|
||||
public function get_contact_us_label() {
|
||||
|
||||
if ($this->contact_us_label === null) {
|
||||
if (null === $this->contact_us_label) {
|
||||
$this->contact_us_label = $this->get_meta('wu_contact_us_label', '');
|
||||
}
|
||||
|
||||
@ -1114,7 +1114,7 @@ class Product extends Base_Model {
|
||||
*/
|
||||
public function get_contact_us_link() {
|
||||
|
||||
if ($this->contact_us_link === null) {
|
||||
if (null === $this->contact_us_link) {
|
||||
$this->contact_us_link = $this->get_meta('wu_contact_us_link', '');
|
||||
}
|
||||
|
||||
@ -1143,7 +1143,7 @@ class Product extends Base_Model {
|
||||
*/
|
||||
public function get_feature_list() {
|
||||
|
||||
if ($this->feature_list === null) {
|
||||
if (null === $this->feature_list) {
|
||||
$this->feature_list = $this->get_meta('feature_list');
|
||||
}
|
||||
|
||||
@ -1172,7 +1172,7 @@ class Product extends Base_Model {
|
||||
*/
|
||||
public function get_customer_role() {
|
||||
|
||||
if ($this->customer_role === null) {
|
||||
if (null === $this->customer_role) {
|
||||
$this->customer_role = $this->get_limitations()->customer_user_role->get_limit();
|
||||
}
|
||||
|
||||
@ -1239,7 +1239,7 @@ class Product extends Base_Model {
|
||||
*/
|
||||
public function get_price_variations() {
|
||||
|
||||
if ($this->price_variations === null) {
|
||||
if (null === $this->price_variations) {
|
||||
$this->price_variations = array_map(
|
||||
function ($price_variation) {
|
||||
/**
|
||||
@ -1372,7 +1372,7 @@ class Product extends Base_Model {
|
||||
*/
|
||||
public function get_available_addons() {
|
||||
|
||||
if ($this->available_addons === null) {
|
||||
if (null === $this->available_addons) {
|
||||
$this->available_addons = $this->get_meta('wu_available_addons', []);
|
||||
|
||||
if (is_string($this->available_addons)) {
|
||||
@ -1440,7 +1440,7 @@ class Product extends Base_Model {
|
||||
*/
|
||||
public function get_legacy_options() {
|
||||
|
||||
if ($this->legacy_options === null) {
|
||||
if (null === $this->legacy_options) {
|
||||
$this->legacy_options = $this->get_meta('legacy_options', false);
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ class Site extends Base_Model {
|
||||
*/
|
||||
public function get_categories() {
|
||||
|
||||
if ($this->categories === null) {
|
||||
if (null === $this->categories) {
|
||||
$this->categories = $this->get_meta('wu_categories', []);
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ class Site extends Base_Model {
|
||||
*/
|
||||
public function get_featured_image_id() {
|
||||
|
||||
if ($this->featured_image_id === null) {
|
||||
if (null === $this->featured_image_id) {
|
||||
return $this->get_meta('wu_featured_image_id');
|
||||
}
|
||||
|
||||
@ -718,7 +718,7 @@ class Site extends Base_Model {
|
||||
*/
|
||||
public function is_active() {
|
||||
|
||||
if ($this->active === null) {
|
||||
if (null === $this->active) {
|
||||
$this->active = $this->get_meta('wu_active', true);
|
||||
}
|
||||
|
||||
@ -885,7 +885,7 @@ class Site extends Base_Model {
|
||||
*/
|
||||
public function get_customer_id() {
|
||||
|
||||
if ($this->customer_id === null) {
|
||||
if (null === $this->customer_id) {
|
||||
$this->customer_id = $this->get_meta('wu_customer_id');
|
||||
}
|
||||
|
||||
@ -950,7 +950,7 @@ class Site extends Base_Model {
|
||||
*/
|
||||
public function get_membership_id() {
|
||||
|
||||
if ($this->membership_id === null) {
|
||||
if (null === $this->membership_id) {
|
||||
$this->membership_id = $this->get_meta('wu_membership_id');
|
||||
}
|
||||
|
||||
@ -1001,7 +1001,7 @@ class Site extends Base_Model {
|
||||
*/
|
||||
public function get_membership() {
|
||||
|
||||
if ($this->_membership !== null) {
|
||||
if (null !== $this->_membership) {
|
||||
return $this->_membership;
|
||||
}
|
||||
|
||||
@ -1057,7 +1057,7 @@ class Site extends Base_Model {
|
||||
*/
|
||||
public function get_template_id() {
|
||||
|
||||
if ($this->template_id === null) {
|
||||
if (null === $this->template_id) {
|
||||
$this->template_id = $this->get_meta('wu_template_id');
|
||||
}
|
||||
|
||||
@ -1152,7 +1152,7 @@ class Site extends Base_Model {
|
||||
return 'main';
|
||||
}
|
||||
|
||||
if ($this->type === null) {
|
||||
if (null === $this->type) {
|
||||
$type = $this->get_meta('wu_type');
|
||||
|
||||
$this->type = $type ?: 'default';
|
||||
@ -1267,7 +1267,7 @@ class Site extends Base_Model {
|
||||
|
||||
$details = get_blog_details($this->get_blog_id());
|
||||
|
||||
if ($details && $this->title === null) {
|
||||
if ($details && null === $this->title) {
|
||||
$this->set_title($details->blogname);
|
||||
}
|
||||
|
||||
@ -1289,7 +1289,7 @@ class Site extends Base_Model {
|
||||
*/
|
||||
public function get_transient() {
|
||||
|
||||
if ($this->transient === null) {
|
||||
if (null === $this->transient) {
|
||||
$this->transient = $this->get_meta('wu_transient');
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ trait Billable {
|
||||
*/
|
||||
public function get_billing_address() {
|
||||
|
||||
if ($this->billing_address === null) {
|
||||
if (null === $this->billing_address) {
|
||||
$billing_address = $this->get_meta('wu_billing_address');
|
||||
|
||||
$this->billing_address = is_a($billing_address, '\WP_Ultimo\Objects\Billing_Address') ? $billing_address : $this->get_default_billing_address();
|
||||
|
@ -159,9 +159,9 @@ trait Limitable {
|
||||
|
||||
$sites = [];
|
||||
|
||||
if ($this->model === 'site') {
|
||||
if ('site' === $this->model) {
|
||||
$sites[] = $this;
|
||||
} elseif ($this->model === 'membership') {
|
||||
} elseif ('membership' === $this->model) {
|
||||
$sites = $this->get_sites();
|
||||
}
|
||||
|
||||
@ -242,12 +242,12 @@ trait Limitable {
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->model !== 'product') {
|
||||
if ('product' !== $this->model) {
|
||||
/*
|
||||
* Set the new permissions, based on the diff.
|
||||
*/
|
||||
$limitations = wu_array_recursive_diff($modules_to_save, $current_limitations->to_array());
|
||||
} elseif ($this->model === 'product' && $this->get_type() !== 'plan') {
|
||||
} elseif ('product' === $this->model && $this->get_type() !== 'plan') {
|
||||
$limitations = wu_array_recursive_diff($modules_to_save, Limitations::get_empty()->to_array());
|
||||
} else {
|
||||
$limitations = $modules_to_save;
|
||||
@ -264,15 +264,15 @@ trait Limitable {
|
||||
*/
|
||||
public function get_applicable_product_slugs() {
|
||||
|
||||
if ($this->model === 'product') {
|
||||
if ('product' === $this->model) {
|
||||
return [$this->get_slug()];
|
||||
}
|
||||
|
||||
$slugs = [];
|
||||
|
||||
if ($this->model === 'membership') {
|
||||
if ('membership' === $this->model) {
|
||||
$membership = $this;
|
||||
} elseif ($this->model === 'site') {
|
||||
} elseif ('site' === $this->model) {
|
||||
$membership = $this->get_membership();
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ trait Notable {
|
||||
*/
|
||||
public function get_notes() {
|
||||
|
||||
if ($this->notes === null) {
|
||||
if (null === $this->notes) {
|
||||
$this->notes = get_metadata($this->get_meta_data_table_name(), $this->get_id(), 'wu_note', false);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user