Fix psalm

This commit is contained in:
dinamiko 2022-05-10 12:18:18 +02:00
parent c77cab9cbe
commit 235c9c8281
3 changed files with 4 additions and 3 deletions

View file

@ -272,7 +272,7 @@ class PayUponInvoice {
}
$birth_date = filter_input( INPUT_POST, 'billing_birth_date', FILTER_SANITIZE_STRING );
if ( ! $this->pui_helper->validate_birth_date( $birth_date ) ) {
if ( $birth_date && ! $this->pui_helper->validate_birth_date( $birth_date ) ) {
$errors->add( 'validation', __( 'Invalid birth date.', 'woocommerce-paypal-payments' ) );
}
},

View file

@ -33,7 +33,8 @@ class PayUponInvoiceHelper {
return false;
}
if ( time() < strtotime( '+18 years', strtotime( $date ) ) ) {
$date_time = strtotime( $date );
if ( $date_time && time() < strtotime( '+18 years', $date_time ) ) {
return false;
}

View file

@ -23,7 +23,7 @@ class PayUponInvoiceHelperTest extends TestCase
['', false],
[(new DateTime())->format($format), false],
[(new DateTime('-17 years'))->format($format), false],
['31-02-1942', false],
['1942-02-31', false],
['01-01-1942', false],
['1942-01-01', true],
];