Fix psalm

This commit is contained in:
Alex P 2022-02-17 18:29:45 +02:00
parent fc89021df4
commit 651099705a
5 changed files with 58 additions and 40 deletions

View file

@ -55,10 +55,12 @@ class PayerFactory {
$national_number = preg_replace( '/[^0-9]/', '', $national_number );
$national_number = substr( $national_number, 0, 14 );
$phone = new PhoneWithType(
'HOME',
new Phone( $national_number )
);
if ( $national_number ) {
$phone = new PhoneWithType(
'HOME',
new Phone( $national_number )
);
}
}
return new Payer(
new PayerName(
@ -91,10 +93,12 @@ class PayerFactory {
$national_number = preg_replace( '/[^0-9]/', '', $national_number );
$national_number = substr( $national_number, 0, 14 );
$phone = new PhoneWithType(
'HOME',
new Phone( $national_number )
);
if ( $national_number ) {
$phone = new PhoneWithType(
'HOME',
new Phone( $national_number )
);
}
}
return new Payer(
new PayerName(
@ -176,10 +180,12 @@ class PayerFactory {
if ( null !== $national_number ) {
$national_number = substr( $national_number, 0, 14 );
$phone = new PhoneWithType(
'HOME',
new Phone( $national_number )
);
if ( $national_number ) {
$phone = new PhoneWithType(
'HOME',
new Phone( $national_number )
);
}
}
}

View file

@ -74,7 +74,10 @@ class ApplicationContextRepository {
$parts = explode( '-', $locale );
if ( count( $parts ) === 3 ) {
return substr( $locale, 0, strrpos( $locale, '-' ) );
$ret = substr( $locale, 0, strrpos( $locale, '-' ) );
if ( false !== $ret ) {
return $ret;
}
}
return 'en';

View file

@ -45,6 +45,8 @@ class CustomerRepository {
}
$unique_id = substr( $this->prefix . strrev( uniqid() ), 0, self::CLIENT_ID_MAX_LENGTH );
assert( is_string( $unique_id ) );
WC()->session->set( 'ppcp_guest_customer_id', $unique_id );
return $unique_id;