Skip to content

Commit

Permalink
Replace native assert with plugin's assert method
Browse files Browse the repository at this point in the history
  • Loading branch information
nmolham-godaddy committed Aug 29, 2024
1 parent 4689185 commit 329227f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ protected function do_transaction( $order ) {
*/
public function add_payment_method() {

assert( $this->supports_add_payment_method() );
$this->get_plugin()->assert( $this->supports_add_payment_method() );

$order = $this->get_order_for_add_payment_method();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ public function add_gateway( $gateway_id, $gateway_class_name ) {
*/
public function get_gateway_class_names() {

assert( ! empty( $this->gateways ) );
$this->assert( ! empty( $this->gateways ) );

$gateway_class_names = array();

Expand All @@ -1295,7 +1295,7 @@ public function get_gateway_class_names() {
*/
public function get_gateway_class_name( $gateway_id ) {

assert( isset( $this->gateways[ $gateway_id ]['gateway_class_name'] ) );
$this->assert( isset( $this->gateways[ $gateway_id ]['gateway_class_name'] ) );

return $this->gateways[ $gateway_id ]['gateway_class_name'];
}
Expand All @@ -1311,7 +1311,7 @@ public function get_gateway_class_name( $gateway_id ) {
*/
public function get_gateways() {

assert( ! empty( $this->gateways ) );
$this->assert( ! empty( $this->gateways ) );

$gateways = array();

Expand Down Expand Up @@ -1385,7 +1385,7 @@ public function has_gateway( $gateway_id ) {
*/
public function get_gateway_ids() {

assert( ! empty( $this->gateways ) );
$this->assert( ! empty( $this->gateways ) );

return array_keys( $this->gateways );
}
Expand Down
24 changes: 12 additions & 12 deletions woocommerce/payment-gateway/class-sv-wc-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ public function get_payment_form_instance() {
*/
public function get_payment_method_defaults() {

assert( $this->supports_payment_form() );
$this->get_plugin()->assert( $this->supports_payment_form() );

$defaults = array(
'account-number' => '',
Expand Down Expand Up @@ -3301,7 +3301,7 @@ public function supports_credit_card_partial_capture() {
*/
protected function add_authorization_charge_form_fields( $form_fields ) {

assert( $this->supports_credit_card_authorization() && $this->supports_credit_card_charge() );
$this->get_plugin()->assert( $this->supports_credit_card_authorization() && $this->supports_credit_card_charge() );

$form_fields['transaction_type'] = array(
'title' => esc_html__( 'Transaction Type', 'woocommerce-plugin-framework' ),
Expand Down Expand Up @@ -3381,7 +3381,7 @@ public function get_authorization_time_window() {
*/
public function perform_credit_card_charge( \WC_Order $order = null ) {

assert( $this->supports_credit_card_charge() );
$this->get_plugin()->assert( $this->supports_credit_card_charge() );

$perform = self::TRANSACTION_TYPE_CHARGE === $this->transaction_type;

Expand Down Expand Up @@ -3412,7 +3412,7 @@ public function perform_credit_card_charge( \WC_Order $order = null ) {
*/
public function perform_credit_card_authorization( \WC_Order $order = null ) {

assert( $this->supports_credit_card_authorization() );
$this->get_plugin()->assert( $this->supports_credit_card_authorization() );

$perform = self::TRANSACTION_TYPE_AUTHORIZATION === $this->transaction_type && ! $this->perform_credit_card_charge( $order );

Expand All @@ -3437,7 +3437,7 @@ public function perform_credit_card_authorization( \WC_Order $order = null ) {
*/
public function is_partial_capture_enabled() {

assert( $this->supports_credit_card_partial_capture() );
$this->get_plugin()->assert( $this->supports_credit_card_partial_capture() );

/**
* Filters whether partial capture is enabled.
Expand Down Expand Up @@ -3516,7 +3516,7 @@ public function supports_card_types() {
*/
public function get_card_types() {

assert( $this->supports_card_types() );
$this->get_plugin()->assert( $this->supports_card_types() );

return is_array( $this->card_types ) ? $this->card_types : [];
}
Expand All @@ -3532,7 +3532,7 @@ public function get_card_types() {
*/
protected function add_card_types_form_fields( $form_fields ) {

assert( $this->supports_card_types() );
$this->get_plugin()->assert( $this->supports_card_types() );

$form_fields['card_types'] = array(
'title' => esc_html__( 'Accepted Card Logos', 'woocommerce-plugin-framework' ),
Expand Down Expand Up @@ -3562,7 +3562,7 @@ protected function add_card_types_form_fields( $form_fields ) {
*/
public function get_available_card_types() {

assert( $this->supports_card_types() );
$this->get_plugin()->assert( $this->supports_card_types() );

// default available card types
if ( ! isset( $this->available_card_types ) ) {
Expand Down Expand Up @@ -3612,7 +3612,7 @@ public function supports_tokenization() {
*/
public function tokenization_enabled() {

assert( $this->supports_tokenization() );
$this->get_plugin()->assert( $this->supports_tokenization() );

return 'yes' == $this->tokenization;
}
Expand All @@ -3627,7 +3627,7 @@ public function tokenization_enabled() {
*/
protected function add_tokenization_form_fields( $form_fields ) {

assert( $this->supports_tokenization() );
$this->get_plugin()->assert( $this->supports_tokenization() );

$form_fields['tokenization'] = array(
/* translators: http://www.cybersource.com/products/payment_security/payment_tokenization/ and https://en.wikipedia.org/wiki/Tokenization_(data_security) */
Expand Down Expand Up @@ -4142,7 +4142,7 @@ public function set_supports( $features ) {
*/
public function supports_check_field( $field_name ) {

assert( $this->is_echeck_gateway() );
$this->get_plugin()->assert( $this->is_echeck_gateway() );

return is_array( $this->supported_check_fields ) && in_array( $field_name, $this->supported_check_fields );

Expand Down Expand Up @@ -4478,7 +4478,7 @@ protected function is_processing_context( string $context ): bool {
public function get_api() {

// concrete stub method
assert( false );
$this->get_plugin()->assert( false );
}


Expand Down

0 comments on commit 329227f

Please sign in to comment.