11<?php
22/**
3- * Copyright 2019-2020, 2022 Optimizely Inc and Contributors
3+ * Copyright 2019-2020, 2022-2023 Optimizely Inc and Contributors
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
77 * You may obtain a copy of the License at
88 *
9- * http ://www.apache.org/licenses/LICENSE-2.0
9+ * https ://www.apache.org/licenses/LICENSE-2.0
1010 *
1111 * Unless required by applicable law or agreed to in writing, software
1212 * distributed under the License is distributed on an "AS IS" BASIS,
@@ -75,7 +75,12 @@ class HTTPProjectConfigManager implements ProjectConfigManagerInterface
7575 /**
7676 * @var String datafile access token.
7777 */
78- private $ datafileAccessToken ;
78+ private $ _datafileAccessToken ;
79+
80+ /**
81+ * @var boolean Flag indicates that the datafile access token is valid.
82+ */
83+ private $ _isDatafileAccessTokenValid ;
7984
8085 public function __construct (
8186 $ sdkKey = null ,
@@ -93,8 +98,8 @@ public function __construct(
9398 $ this ->_logger = $ logger ?: new NoOpLogger ();
9499 $ this ->_errorHandler = $ errorHandler ?: new NoOpErrorHandler ();
95100 $ 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 );
98103
99104 $ this ->httpClient = new HttpClient ();
100105 $ this ->_url = $ this ->getUrl ($ sdkKey , $ url , $ urlTemplate );
@@ -136,7 +141,7 @@ protected function getUrl($sdkKey, $url, $urlTemplate)
136141 }
137142
138143 if (!Validator::validateNonEmptyString ($ urlTemplate )) {
139- if ($ this ->isDatafileAccessTokenValid ) {
144+ if ($ this ->_isDatafileAccessTokenValid ) {
140145 $ urlTemplate = ProjectConfigManagerConstants::AUTHENTICATED_DATAFILE_URL_TEMPLATE ;
141146 } else {
142147 $ urlTemplate = ProjectConfigManagerConstants::DEFAULT_DATAFILE_URL_TEMPLATE ;
@@ -179,8 +184,8 @@ protected function fetchDatafile()
179184 }
180185
181186 // 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 }" ;
184189 }
185190
186191 $ options = [
0 commit comments