Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Features
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
3 / 3
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 declare_cart_checkout_blocks_compatibility
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 declare_hpos_compatibility
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * Declare compatability with WooCommerce features, i.e. HPOS.
4 *
5 * @package brianhenryie/bh-wc-postcode-address-autofill
6 */
7
8namespace BrianHenryIE\WC_Postcode_Address_Autofill\WooCommerce;
9
10use Automattic\WooCommerce\Utilities\FeaturesUtil;
11use BrianHenryIE\WC_Postcode_Address_Autofill\Settings_Interface;
12
13/**
14 * Declare compatibility with WooCommerce High Performance Order Storage.
15 */
16class Features {
17    /**
18     * For the plugin basename.
19     */
20    protected Settings_Interface $settings;
21
22    /**
23     * Constructor
24     *
25     * @param Settings_Interface $settings The plugin's settings.
26     */
27    public function __construct( Settings_Interface $settings ) {
28        $this->settings = $settings;
29    }
30
31    /**
32     * Register compatibility with WooCommerce Blocks cart and checkout.
33     *
34     * @hooked before_woocommerce_init
35     */
36    public function declare_cart_checkout_blocks_compatibility(): void {
37        if ( ! class_exists( FeaturesUtil::class ) ) {
38            return;
39        }
40
41        FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', $this->settings->get_plugin_basename(), true );
42    }
43
44    /**
45     * Register compatibility with HPOS.
46     *
47     * We do not use anything with orders.
48     *
49     * @hooked before_woocommerce_init
50     */
51    public function declare_hpos_compatibility(): void {
52        if ( ! class_exists( FeaturesUtil::class ) ) {
53            return;
54        }
55
56        FeaturesUtil::declare_compatibility( 'custom_order_tables', $this->settings->get_plugin_basename(), true );
57    }
58}