From 076dc0289b463217ff644924d1bf44a542b75c2a Mon Sep 17 00:00:00 2001 From: padams Date: Sun, 7 Nov 2021 23:59:11 +0000 Subject: [PATCH] allow passing of credentials to clients via constructor. --- src/OwaClient.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/OwaClient.php b/src/OwaClient.php index 3ac9d84..ca49f71 100644 --- a/src/OwaClient.php +++ b/src/OwaClient.php @@ -13,7 +13,8 @@ public function __construct( $config ) { 'instance_url' => '', 'ns' => 'owa_', - 'endpoint' => 'api' + 'endpoint' => 'api', + 'credentials' => [] ]; // override default config with config array passed in. @@ -36,9 +37,7 @@ public function setSetting( $name, $value ) { public function getCredentials() { - static $credentials; - - if ( empty ( $credentials ) ) { + if ( empty ( $this->config['credentials'] ) ) { $credentials = [ @@ -60,8 +59,7 @@ public function getCredentials() { if ( defined('OWA_API_KEY') ) { $credentials['api_key'] = OWA_API_KEY; - } - + } } // check environment variables @@ -78,7 +76,6 @@ public function getCredentials() { $credentials['auth_key'] = OWA_AUTH_KEY; } - } //check credentials file in home dir. @@ -97,10 +94,11 @@ public function getCredentials() { } } } - + + $this->config['credentials'] = $credentials; } - return $credentials; + return $this->config['credentials']; } private function getHomeDirectory() {