Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Check_Address_For_Payment_Service_Result | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| is_paid | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Query data; resolved transactions; value sent to address. |
| 4 | * |
| 5 | * @package brianhenryie/bh-wp-bitcoin-gateway |
| 6 | */ |
| 7 | |
| 8 | namespace BrianHenryIE\WP_Bitcoin_Gateway\API\Services\Results; |
| 9 | |
| 10 | use BrianHenryIE\WP_Bitcoin_Gateway\API\Model\Results\Update_Address_Transactions_Result; |
| 11 | use BrianHenryIE\WP_Bitcoin_Gateway\API\Services\Payment_Service; |
| 12 | use BrianHenryIE\WP_Bitcoin_Gateway\Brick\Money\Money; |
| 13 | |
| 14 | /** |
| 15 | * @used-by Payment_Service::check_address_for_payment() |
| 16 | * @see Payment_Service::update_address_transactions() |
| 17 | */ |
| 18 | readonly class Check_Address_For_Payment_Service_Result extends Update_Address_Transactions_Result { |
| 19 | |
| 20 | /** |
| 21 | * Constructor |
| 22 | * |
| 23 | * @param Update_Address_Transactions_Result $update_address_transactions_result We first must update transactions before performing the calculations. |
| 24 | * @param int $blockchain_height The current blockchain height. |
| 25 | * @param int $required_confirmations The required confirmations to consider this "paid". |
| 26 | * @param Money $confirmed_received The total received with the required confirmations. |
| 27 | */ |
| 28 | public function __construct( |
| 29 | protected Update_Address_Transactions_Result $update_address_transactions_result, // This is accessed by subclass. |
| 30 | public int $blockchain_height, |
| 31 | public int $required_confirmations, |
| 32 | public Money $confirmed_received, |
| 33 | ) { |
| 34 | parent::__construct( |
| 35 | queried_address: $update_address_transactions_result->queried_address, |
| 36 | known_tx_ids_before: $update_address_transactions_result->known_tx_ids_before, |
| 37 | all_transactions: $update_address_transactions_result->all_transactions, |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Is the confirmed amount greater than the required amount. |
| 43 | * |
| 44 | * If the `target_amount` is `null` (addresses that have not been assigned to orders), this will return false. |
| 45 | */ |
| 46 | public function is_paid(): bool { |
| 47 | return (bool) $this->queried_address->get_target_amount()?->isLessThanOrEqualTo( $this->confirmed_received ); |
| 48 | } |
| 49 | } |