| 1 |
<?php |
| 2 |
|
| 3 |
// @phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- This namespace should reflect the namespace of the original class. |
| 4 |
namespace Yoast\WP\SEO\Editors\Framework\Integrations; |
| 5 |
|
| 6 |
use Yoast\WP\SEO\Conditionals\WooCommerce_Conditional; |
| 7 |
use Yoast\WP\SEO\Editors\Domain\Integrations\Integration_Data_Provider_Interface; |
| 8 |
|
| 9 |
/** |
| 10 |
* Describes if the Woocommerce plugin is enabled. |
| 11 |
*/ |
| 12 |
class WooCommerce implements Integration_Data_Provider_Interface { |
| 13 |
|
| 14 |
/** |
| 15 |
* The WooCommerce conditional. |
| 16 |
* |
| 17 |
* @var WooCommerce_Conditional |
| 18 |
*/ |
| 19 |
private $woocommerce_conditional; |
| 20 |
|
| 21 |
/** |
| 22 |
* The constructor. |
| 23 |
* |
| 24 |
* @param WooCommerce_Conditional $woocommerce_conditional The WooCommerce conditional. |
| 25 |
*/ |
| 26 |
public function __construct( WooCommerce_Conditional $woocommerce_conditional ) { |
| 27 |
$this->woocommerce_conditional = $woocommerce_conditional; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* If the plugin is activated. |
| 32 |
* |
| 33 |
* @return bool If the plugin is activated. |
| 34 |
*/ |
| 35 |
public function is_enabled(): bool { |
| 36 |
return $this->woocommerce_conditional->is_met(); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Return this object represented by a key value array. |
| 41 |
* |
| 42 |
* @return array<string, bool> Returns the name and if the feature is enabled. |
| 43 |
*/ |
| 44 |
public function to_array(): array { |
| 45 |
return [ 'isWooCommerceActive' => $this->is_enabled() ]; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Returns this object represented by a key value structure that is compliant with the script data array. |
| 50 |
* |
| 51 |
* @return array<string, bool> Returns the legacy key and if the feature is enabled. |
| 52 |
*/ |
| 53 |
public function to_legacy_array(): array { |
| 54 |
return [ 'isWooCommerceActive' => $this->is_enabled() ]; |
| 55 |
} |
| 56 |
} |
| 57 |
|