mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
🚚 Extract Environment class to gateway module
This commit is contained in:
parent
d186677a58
commit
90d2c77a5a
28 changed files with 32 additions and 34 deletions
|
@ -11,7 +11,7 @@ namespace WooCommerce\PayPalCommerce\Onboarding\Assets;
|
|||
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Endpoint\LoginSellerEndpoint;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Endpoint\UpdateSignupLinksEndpoint;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\Environment;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Used to detect the current environment.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\Onboarding
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\Onboarding;
|
||||
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Class Environment
|
||||
*/
|
||||
class Environment {
|
||||
|
||||
|
||||
const PRODUCTION = 'production';
|
||||
const SANDBOX = 'sandbox';
|
||||
|
||||
/**
|
||||
* The Settings.
|
||||
*
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* Environment constructor.
|
||||
*
|
||||
* @param ContainerInterface $settings The Settings.
|
||||
*/
|
||||
public function __construct( ContainerInterface $settings ) {
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current environment.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function current_environment(): string {
|
||||
return (
|
||||
$this->settings->has( 'sandbox_on' ) && $this->settings->get( 'sandbox_on' )
|
||||
) ? self::SANDBOX : self::PRODUCTION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect whether the current environment equals $environment
|
||||
*
|
||||
* @param string $environment The value to check against.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function current_environment_is( string $environment ): bool {
|
||||
return $this->current_environment() === $environment;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue