1
1
<?php
2
2
/**
3
- * Copyright 2019-2020, 2022 Optimizely Inc and Contributors
3
+ * Copyright 2019-2020, 2022-2023 Optimizely Inc and Contributors
4
4
*
5
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
6
* you may not use this file except in compliance with the License.
7
7
* You may obtain a copy of the License at
8
8
*
9
- * http ://www.apache.org/licenses/LICENSE-2.0
9
+ * https ://www.apache.org/licenses/LICENSE-2.0
10
10
*
11
11
* Unless required by applicable law or agreed to in writing, software
12
12
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -75,7 +75,12 @@ class HTTPProjectConfigManager implements ProjectConfigManagerInterface
75
75
/**
76
76
* @var String datafile access token.
77
77
*/
78
- private $ datafileAccessToken ;
78
+ private $ _datafileAccessToken ;
79
+
80
+ /**
81
+ * @var boolean Flag indicates that the datafile access token is valid.
82
+ */
83
+ private $ _isDatafileAccessTokenValid ;
79
84
80
85
public function __construct (
81
86
$ sdkKey = null ,
@@ -93,8 +98,8 @@ public function __construct(
93
98
$ this ->_logger = $ logger ?: new NoOpLogger ();
94
99
$ this ->_errorHandler = $ errorHandler ?: new NoOpErrorHandler ();
95
100
$ this ->_notificationCenter = $ notificationCenter ?: new NotificationCenter ($ this ->_logger , $ this ->_errorHandler );
96
- $ this ->datafileAccessToken = $ datafileAccessToken ;
97
- $ this ->isDatafileAccessTokenValid = Validator::validateNonEmptyString ($ this ->datafileAccessToken );
101
+ $ this ->_datafileAccessToken = $ datafileAccessToken ;
102
+ $ this ->_isDatafileAccessTokenValid = Validator::validateNonEmptyString ($ this ->_datafileAccessToken );
98
103
99
104
$ this ->httpClient = new HttpClient ();
100
105
$ this ->_url = $ this ->getUrl ($ sdkKey , $ url , $ urlTemplate );
@@ -136,7 +141,7 @@ protected function getUrl($sdkKey, $url, $urlTemplate)
136
141
}
137
142
138
143
if (!Validator::validateNonEmptyString ($ urlTemplate )) {
139
- if ($ this ->isDatafileAccessTokenValid ) {
144
+ if ($ this ->_isDatafileAccessTokenValid ) {
140
145
$ urlTemplate = ProjectConfigManagerConstants::AUTHENTICATED_DATAFILE_URL_TEMPLATE ;
141
146
} else {
142
147
$ urlTemplate = ProjectConfigManagerConstants::DEFAULT_DATAFILE_URL_TEMPLATE ;
@@ -179,8 +184,8 @@ protected function fetchDatafile()
179
184
}
180
185
181
186
// Add Authorization header if access token available.
182
- if ($ this ->isDatafileAccessTokenValid ) {
183
- $ headers ['Authorization ' ] = "Bearer {$ this ->datafileAccessToken }" ;
187
+ if ($ this ->_isDatafileAccessTokenValid ) {
188
+ $ headers ['Authorization ' ] = "Bearer {$ this ->_datafileAccessToken }" ;
184
189
}
185
190
186
191
$ options = [
0 commit comments