diff --git a/modules/ppcp-api-client/src/Authentication/ClientCredentials.php b/modules/ppcp-api-client/src/Authentication/ClientCredentials.php index 7ec4628a5..08d37bead 100644 --- a/modules/ppcp-api-client/src/Authentication/ClientCredentials.php +++ b/modules/ppcp-api-client/src/Authentication/ClientCredentials.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\ApiClient\Authentication; use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; +use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException; /** * Class ClientCredentials @@ -28,14 +29,21 @@ class ClientCredentials { * * @param Settings $settings The settings. */ - public function __construct(Settings $settings) { + public function __construct( Settings $settings ) { $this->settings = $settings; } + /** + * Returns encoded client credentials. + * + * @return string + * @throws NotFoundException If setting does not found. + */ public function credentials(): string { - $client_id = $this->settings->has( 'client_id' ) ? $this->settings->get( 'client_id' ) : ''; + $client_id = $this->settings->has( 'client_id' ) ? $this->settings->get( 'client_id' ) : ''; $client_secret = $this->settings->has( 'client_secret' ) ? $this->settings->get( 'client_secret' ) : ''; - return 'Basic ' . base64_encode($client_id . ':' . $client_secret); + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode + return 'Basic ' . base64_encode( $client_id . ':' . $client_secret ); } }