| 1 |
<?php |
| 2 |
/** |
| 3 |
* Platform Provider Interface |
| 4 |
* |
| 5 |
* @package SeQura/WC |
| 6 |
* @subpackage SeQura/WC/Services |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace SeQura\WC\Services\Platform; |
| 10 |
|
| 11 |
use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Platform; |
| 12 |
use SeQura\WC\Services\Constants\Interface_Constants; |
| 13 |
|
| 14 |
/** |
| 15 |
* Provide the current platform |
| 16 |
*/ |
| 17 |
class Platform_Provider implements Interface_Platform_Provider { |
| 18 |
|
| 19 |
/** |
| 20 |
* Constants service |
| 21 |
* |
| 22 |
* @var Interface_Constants |
| 23 |
*/ |
| 24 |
private $constants; |
| 25 |
|
| 26 |
/** |
| 27 |
* Platform instance |
| 28 |
* |
| 29 |
* @var Platform |
| 30 |
*/ |
| 31 |
private $platform; |
| 32 |
|
| 33 |
/** |
| 34 |
* Constructor |
| 35 |
*/ |
| 36 |
public function __construct( Interface_Constants $constants ) { |
| 37 |
$this->constants = $constants; |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Get the current platform |
| 42 |
*/ |
| 43 |
public function get(): Platform { |
| 44 |
if ( ! $this->platform ) { |
| 45 |
/** |
| 46 |
* WooCommerce data |
| 47 |
* |
| 48 |
* @var array<string, string> |
| 49 |
*/ |
| 50 |
$woo = $this->constants->get_woocommerce_data(); |
| 51 |
|
| 52 |
/** |
| 53 |
* Environment data |
| 54 |
* |
| 55 |
* @var array<string, string> |
| 56 |
*/ |
| 57 |
$env = $this->constants->get_environment_data(); |
| 58 |
|
| 59 |
/** |
| 60 |
* Plugin data |
| 61 |
* |
| 62 |
* @var array<string, string> |
| 63 |
*/ |
| 64 |
$sq = $this->constants->get_plugin_data(); |
| 65 |
|
| 66 |
/** |
| 67 |
* Filter the module version to be used in the platform options. |
| 68 |
* |
| 69 |
* @since 3.0.0 |
| 70 |
*/ |
| 71 |
$version = \apply_filters( |
| 72 |
'sequra_platform_options_version', |
| 73 |
$sq['Version'] ?? '' |
| 74 |
); |
| 75 |
|
| 76 |
$platform_version = ( $woo['Version'] ?? '' ) . ( isset( $env['wp_version'] ) ? " + WordPress {$env['wp_version']}" : '' ); |
| 77 |
|
| 78 |
/** |
| 79 |
* Filter the platform options. |
| 80 |
* |
| 81 |
* @since 3.0.0 |
| 82 |
*/ |
| 83 |
$this->platform = \apply_filters( |
| 84 |
'sequra_platform_options', |
| 85 |
new Platform( |
| 86 |
$this->constants->get_integration_name(), |
| 87 |
$platform_version, |
| 88 |
$env['uname'], |
| 89 |
$env['db_name'], |
| 90 |
$env['db_version'], |
| 91 |
$version, |
| 92 |
$env['php_version'] |
| 93 |
) |
| 94 |
); |
| 95 |
} |
| 96 |
return $this->platform; |
| 97 |
} |
| 98 |
} |
| 99 |
|