Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
3 / 4
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
HPOS
75.00% covered (warning)
75.00%
3 / 4
50.00% covered (danger)
50.00%
1 / 2
3.14
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 declare_compatibility
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
2.15
1<?php
2/**
3 * Declare compatibility with WooCommere's new High Performance Order Storage (database tables).
4 *
5 * Rather, assert we are not doing anything incompatible!
6 *
7 * @see https://github.com/woocommerce/woocommerce/wiki/High-Performance-Order-Storage-Upgrade-Recipe-Book#declaring-extension-incompatibility
8 *
9 * @package brianhenryie/bh-wp-bitcoin-gateway
10 */
11
12namespace BrianHenryIE\WP_Bitcoin_Gateway\WooCommerce;
13
14use Automattic\WooCommerce\Utilities\FeaturesUtil;
15use BrianHenryIE\WP_Bitcoin_Gateway\Settings_Interface;
16
17/**
18 * Message FeaturesUtil that this plugin has no incompatibilities with HPOS.
19 *
20 * @see https://woocommerce.com/document/high-performance-order-storage/
21 */
22class HPOS {
23
24    /**
25     * For the plugin basename.
26     */
27    protected Settings_Interface $settings;
28
29    /**
30     * Constructor
31     *
32     * @param Settings_Interface $settings The plugin's settings.
33     */
34    public function __construct( Settings_Interface $settings ) {
35        $this->settings = $settings;
36    }
37
38    /**
39     * Register compatibility with HPOS.
40     *
41     * We do not use any funky SQL for orders, just WooCommerce's CRUD function.
42     *
43     * @hooked before_woocommerce_init
44     */
45    public function declare_compatibility(): void {
46        if ( ! class_exists( FeaturesUtil::class ) ) {
47            return;
48        }
49
50        FeaturesUtil::declare_compatibility( 'custom_order_tables', $this->settings->get_plugin_basename(), true );
51    }
52}