Conditions | 2 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
26 | public static function get_invoice_number( $invoice_number, Payment $payment ) { |
||
27 | // Replacements definition |
||
28 | $replacements = array( |
||
29 | '{order_id}' => $payment->get_order_id(), |
||
30 | '{payment_id}' => $payment->get_id(), |
||
31 | ); |
||
32 | |||
33 | // Find and replace |
||
34 | $invoice_number = str_replace( |
||
35 | array_keys( $replacements ), |
||
36 | array_values( $replacements ), |
||
37 | $invoice_number, |
||
38 | $count |
||
39 | ); |
||
40 | |||
41 | // Make sure there is an dynamic part in the order ID |
||
42 | if ( 0 === $count ) { |
||
43 | $invoice_number .= $payment->get_id(); |
||
44 | } |
||
45 | |||
46 | return $invoice_number; |
||
47 | } |
||
49 |