Skip to content

Commit

Permalink
Simplify by using early returns.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Oct 26, 2023
1 parent 97385aa commit c8de0ca
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/Payments/PaymentsDataStoreCPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,29 @@ public function __construct() {
* @return Payment|null
*/
public function get_payment( $id ) {
if ( ! isset( $this->payments[ $id ] ) ) {
if ( empty( $id ) ) {
return null;
}
if ( \array_key_exists( $id, $this->payments ) ) {
return $this->payments[ $id ];
}

if ( empty( $id ) ) {
return null;
}

$id = (int) $id;
$id = (int) $id;

$post_type = get_post_type( $id );
$post_type = \get_post_type( $id );

if ( 'pronamic_payment' !== $post_type ) {
return null;
}
if ( 'pronamic_payment' !== $post_type ) {
return null;
}

$payment = new Payment();
$payment = new Payment();

$payment->set_id( $id );
$payment->set_id( $id );

$this->payments[ $id ] = $payment;
$this->payments[ $id ] = $payment;

$this->read( $payment );
}
$this->read( $payment );

return $this->payments[ $id ];
}
Expand Down

0 comments on commit c8de0ca

Please sign in to comment.