Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
| Bitcoin_Transaction | |
0.00% |
0 / 8 |
|
0.00% |
0 / 8 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_post_id | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_txid | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_block_time | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_block_height | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_version | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_v_in | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_v_out | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Saved Bitcoin transaction stored as a WordPress custom post type. |
| 4 | * |
| 5 | * TODO: record the API that the transaction was found on. |
| 6 | * |
| 7 | * @package brianhenryie/bh-wp-bitcoin-gateway |
| 8 | */ |
| 9 | |
| 10 | namespace BrianHenryIE\WP_Bitcoin_Gateway\API\Model\Payments; |
| 11 | |
| 12 | use DateTimeInterface; |
| 13 | |
| 14 | /** |
| 15 | * Wraps a Transaction object from the blockchain API along with metadata about |
| 16 | * which Bitcoin addresses in the system are associated with this transaction. |
| 17 | * |
| 18 | * @phpstan-type WpUpdatePostArray array{ID?: int, post_author?: int, post_date?: string, post_date_gmt?: string, post_content?: string, post_content_filtered?: string, post_title?: string, post_excerpt?: string} |
| 19 | */ |
| 20 | readonly class Bitcoin_Transaction implements Transaction_Interface { |
| 21 | |
| 22 | /** |
| 23 | * Constructor |
| 24 | * |
| 25 | * @param int $post_id The WordPress post ID for this transaction. |
| 26 | * @param Transaction $transaction The transaction object. |
| 27 | * @param array<int,string> $bitcoin_addresses Bitcoin addresses as post_id:bitcoin_address pairs. |
| 28 | */ |
| 29 | public function __construct( |
| 30 | protected int $post_id, |
| 31 | protected Transaction $transaction, |
| 32 | protected array $bitcoin_addresses, |
| 33 | ) { |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get the WordPress post ID for this transaction. |
| 38 | * |
| 39 | * @return int The post ID. |
| 40 | */ |
| 41 | public function get_post_id(): int { |
| 42 | return $this->post_id; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Get the transaction ID (txid/hash). |
| 47 | */ |
| 48 | public function get_txid(): string { |
| 49 | return $this->transaction->get_txid(); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Get the block time for this transaction. |
| 54 | */ |
| 55 | public function get_block_time(): DateTimeInterface { |
| 56 | return $this->transaction->get_block_time(); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Get the block height for this transaction. (TODO null if unconfirmed?). |
| 61 | */ |
| 62 | public function get_block_height(): ?int { |
| 63 | return $this->transaction->get_block_height(); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Get the transaction version, "1" or "2". |
| 68 | */ |
| 69 | public function get_version(): int { |
| 70 | return $this->transaction->get_version(); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @return Transaction_VIn[] |
| 75 | */ |
| 76 | public function get_v_in(): array { |
| 77 | return $this->transaction->get_v_in(); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @return Transaction_VOut[] |
| 82 | */ |
| 83 | public function get_v_out(): array { |
| 84 | return $this->transaction->get_v_out(); |
| 85 | } |
| 86 | } |