mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Fix phpcs errors
This commit is contained in:
parent
22e60d1448
commit
817a460666
3 changed files with 31 additions and 27 deletions
|
@ -24,12 +24,15 @@ class PayPalBearer implements Bearer {
|
|||
use RequestTrait;
|
||||
|
||||
const CACHE_KEY = 'ppcp-bearer';
|
||||
/**
|
||||
* @var Settings
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The settings.
|
||||
*
|
||||
* @var Settings
|
||||
*/
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* The cache.
|
||||
*
|
||||
* @var Cache
|
||||
|
@ -72,6 +75,7 @@ class PayPalBearer implements Bearer {
|
|||
* @param string $key The key.
|
||||
* @param string $secret The secret.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param Settings $settings The settings.
|
||||
*/
|
||||
public function __construct(
|
||||
Cache $cache,
|
||||
|
@ -79,16 +83,16 @@ class PayPalBearer implements Bearer {
|
|||
string $key,
|
||||
string $secret,
|
||||
LoggerInterface $logger,
|
||||
Settings $settings
|
||||
Settings $settings
|
||||
) {
|
||||
|
||||
$this->cache = $cache;
|
||||
$this->host = $host;
|
||||
$this->key = $key;
|
||||
$this->secret = $secret;
|
||||
$this->logger = $logger;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
$this->cache = $cache;
|
||||
$this->host = $host;
|
||||
$this->key = $key;
|
||||
$this->secret = $secret;
|
||||
$this->logger = $logger;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bearer token.
|
||||
|
@ -112,15 +116,15 @@ class PayPalBearer implements Bearer {
|
|||
* @throws RuntimeException When request fails.
|
||||
*/
|
||||
private function newBearer(): Token {
|
||||
$key = $this->settings->has('client_id') && $this->settings->get('client_id') ? $this->settings->get('client_id') : $this->key;
|
||||
$secret = $this->settings->has('client_secret') && $this->settings->get('client_secret') ? $this->settings->get('client_secret') : $this->secret;
|
||||
$url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials';
|
||||
$key = $this->settings->has( 'client_id' ) && $this->settings->get( 'client_id' ) ? $this->settings->get( 'client_id' ) : $this->key;
|
||||
$secret = $this->settings->has( 'client_secret' ) && $this->settings->get( 'client_secret' ) ? $this->settings->get( 'client_secret' ) : $this->secret;
|
||||
$url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials';
|
||||
|
||||
$args = array(
|
||||
$args = array(
|
||||
'method' => 'POST',
|
||||
'headers' => array(
|
||||
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
|
||||
'Authorization' => 'Basic ' . base64_encode( $key . ':' . $secret),
|
||||
'Authorization' => 'Basic ' . base64_encode( $key . ':' . $secret ),
|
||||
),
|
||||
);
|
||||
$response = $this->request(
|
||||
|
|
|
@ -105,14 +105,14 @@ return array(
|
|||
$secret = $container->get( 'api.secret' );
|
||||
$host = $container->get( 'api.host' );
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
$settings = $container->get('wcgateway.settings');
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
return new PayPalBearer(
|
||||
$cache,
|
||||
$host,
|
||||
$key,
|
||||
$secret,
|
||||
$logger,
|
||||
$settings
|
||||
$settings
|
||||
);
|
||||
},
|
||||
'onboarding.state' => function( $container ) : State {
|
||||
|
|
|
@ -43,7 +43,7 @@ class StatusReportModule implements ModuleInterface {
|
|||
public function run( ContainerInterface $container ): void {
|
||||
add_action(
|
||||
'woocommerce_system_status_report',
|
||||
function () use ($container) {
|
||||
function () use ( $container ) {
|
||||
|
||||
/* @var State $state The state. */
|
||||
$state = $container->get( 'onboarding.state' );
|
||||
|
@ -106,22 +106,22 @@ class StatusReportModule implements ModuleInterface {
|
|||
* It returns the current onboarding status.
|
||||
*
|
||||
* @param Bearer $bearer The bearer.
|
||||
* @param State $state The state.
|
||||
* @param State $state The state.
|
||||
* @return string
|
||||
*/
|
||||
private function onboarded( $bearer, $state): string {
|
||||
private function onboarded( $bearer, $state ): string {
|
||||
try {
|
||||
$token = $bearer->bearer();
|
||||
} catch ( RuntimeException $exception ) {
|
||||
return esc_html__('No', 'woocommerce-paypal-payments');
|
||||
return esc_html__( 'No', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
|
||||
$current_state = $state->current_state();
|
||||
if($token->is_valid() && $current_state === $state::STATE_ONBOARDED) {
|
||||
return esc_html__('Yes', 'woocommerce-paypal-payments');
|
||||
if ( $token->is_valid() && $current_state === $state::STATE_ONBOARDED ) {
|
||||
return esc_html__( 'Yes', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
|
||||
return esc_html__('No', 'woocommerce-paypal-payments');
|
||||
return esc_html__( 'No', 'woocommerce-paypal-payments' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue