Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
16 / 16 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| Bitcoin_Wallet_Query | |
100.00% |
16 / 16 |
|
100.00% |
4 / 4 |
8 | |
100.00% |
1 / 1 |
| get_post_type | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_wp_post_fields | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
5 | |||
| get_meta_input | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Strongly typed object for querying Bitcoin_Wallet in wp_posts table. |
| 4 | * |
| 5 | * @package brianhenryie/bh-wp-bitcoin-gateway |
| 6 | */ |
| 7 | |
| 8 | namespace BrianHenryIE\WP_Bitcoin_Gateway\API\Repositories\Queries; |
| 9 | |
| 10 | use BrianHenryIE\WP_Bitcoin_Gateway\API\Model\Wallet\Bitcoin_Wallet_Status; |
| 11 | use BrianHenryIE\WP_Bitcoin_Gateway\API\Model\Wallet\Bitcoin_Wallet_WP_Post_Interface; |
| 12 | use BrianHenryIE\WP_Bitcoin_Gateway\WP_Includes\Post_BH_Bitcoin_Wallet; |
| 13 | |
| 14 | /** |
| 15 | * @see Post_BH_Bitcoin_Wallet |
| 16 | */ |
| 17 | readonly class Bitcoin_Wallet_Query extends WP_Post_Query_Abstract { |
| 18 | |
| 19 | /** |
| 20 | * The Bitcoin_Wallet wp_post post_type. |
| 21 | */ |
| 22 | protected function get_post_type(): string { |
| 23 | return Bitcoin_Wallet_WP_Post_Interface::POST_TYPE; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * |
| 28 | * @return array<string,mixed> $map to:from |
| 29 | */ |
| 30 | #[\Override] |
| 31 | protected function get_wp_post_fields(): array { |
| 32 | $wp_post_fields = array(); |
| 33 | |
| 34 | if ( $this->master_public_key ) { |
| 35 | $wp_post_fields['post_title'] = $this->master_public_key; |
| 36 | } |
| 37 | if ( $this->master_public_key ) { |
| 38 | $wp_post_fields['post_title'] = $this->master_public_key; |
| 39 | } |
| 40 | if ( $this->status ) { |
| 41 | $wp_post_fields['post_status'] = $this->status; |
| 42 | } |
| 43 | if ( $this->master_public_key ) { |
| 44 | $wp_post_fields['post_name'] = sanitize_title( $this->master_public_key ); |
| 45 | } |
| 46 | |
| 47 | return $wp_post_fields; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * @return array<string,mixed> |
| 52 | */ |
| 53 | protected function get_meta_input(): array { |
| 54 | return array( |
| 55 | Bitcoin_Wallet_WP_Post_Interface::GATEWAYS_DETAILS_META_KEY => $this->gateway_refs, |
| 56 | Bitcoin_Wallet_WP_Post_Interface::LAST_DERIVED_ADDRESS_INDEX_META_KEY => $this->last_derived_address_index, |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Constructor. |
| 62 | * |
| 63 | * @param ?string $master_public_key The Wallet's master public key. |
| 64 | * @param ?Bitcoin_Wallet_Status $status Current status, e.g. new. |
| 65 | * @param ?array<array{integration:class-string, gateway_id:string}> $gateway_refs List of gateways the Bitcoin_Wallet is being used by. |
| 66 | * @param ?int $last_derived_address_index The highest address index that has been derived from this wallet's master public key. |
| 67 | */ |
| 68 | public function __construct( |
| 69 | public ?string $master_public_key = null, |
| 70 | public ?Bitcoin_Wallet_Status $status = null, |
| 71 | public ?array $gateway_refs = null, |
| 72 | public ?int $last_derived_address_index = null, |
| 73 | ) { |
| 74 | parent::__construct(); |
| 75 | } |
| 76 | } |