7
7
use Twilio \Http \BearerToken \ApiTokenManager ;
8
8
use Twilio \Http \BearerToken \TokenManager ;
9
9
10
-
10
+ /**
11
+ * Class ClientCredentialProvider
12
+ * Credential provider for OAuth in public apis
13
+ */
11
14
class ClientCredentialProvider extends CredentialProvider {
15
+ /**
16
+ * @var array $options - array of params required for token api
17
+ */
12
18
private $ options ;
19
+
20
+ /**
21
+ * @var TokenManager $tokenManager - handles fetching and refreshing of token
22
+ */
13
23
private $ tokenManager ;
14
24
15
25
public function __construct () {
@@ -40,7 +50,12 @@ public function setTokenManager(TokenManager $tokenManager): void {
40
50
$ this ->tokenManager = $ tokenManager ;
41
51
}
42
52
43
-
53
+ /**
54
+ * Magic method to get properties - returns the property if it exists in the options array
55
+ * @param string $name
56
+ * @return mixed value of the property
57
+ * @throws TwilioException
58
+ */
44
59
public function __get (string $ name )
45
60
{
46
61
if (array_key_exists ($ name , $ this ->options )) {
@@ -49,6 +64,13 @@ public function __get(string $name)
49
64
throw new TwilioException ('Unknown property ' . $ name );
50
65
}
51
66
67
+ /**
68
+ * Magic method to set properties - sets the value of the property if it exists in the options array
69
+ * @param string $name
70
+ * @param $value
71
+ * @return void
72
+ * @throws TwilioException
73
+ */
52
74
public function __set (string $ name , $ value )
53
75
{
54
76
if (array_key_exists ($ name , $ this ->options )) {
@@ -58,6 +80,10 @@ public function __set(string $name, $value)
58
80
}
59
81
}
60
82
83
+ /**
84
+ * Returns TokenAuthStrategy using ApiTokenManager
85
+ * @return AuthStrategy
86
+ */
61
87
public function toAuthStrategy (): AuthStrategy {
62
88
if ($ this ->tokenManager === null ) {
63
89
$ this ->tokenManager = new ApiTokenManager ($ this ->options );
0 commit comments