Skip to content

Commit 3d18ab2

Browse files
authored
Fix PHP CS Fixer errors (#50)
1 parent 11a6224 commit 3d18ab2

10 files changed

+332
-332
lines changed

src/ConfigCatClient.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ public function getValue(string $key, mixed $defaultValue, ?User $user = null):
181181
$settingsResult->fetchTime
182182
)->getValue();
183183
} catch (Throwable $exception) {
184-
$message = "Error occurred in the `getValue` method while evaluating setting '".$key."'. ".
185-
'Returning the `defaultValue` parameter that you specified '.
186-
"in your application: '".Utils::getStringRepresentation($defaultValue)."'.";
184+
$message = "Error occurred in the `getValue` method while evaluating setting '".$key."'. "
185+
.'Returning the `defaultValue` parameter that you specified '
186+
."in your application: '".Utils::getStringRepresentation($defaultValue)."'.";
187187
$messageCtx = [
188188
'event_id' => 1002, 'exception' => $exception,
189189
];
@@ -228,9 +228,9 @@ public function getValueDetails(string $key, mixed $defaultValue, ?User $user =
228228

229229
return $this->evaluate($key, $settingsResult->settings, $defaultValue, $user, $settingsResult->fetchTime);
230230
} catch (Throwable $exception) {
231-
$message = "Error occurred in the `getValueDetails` method while evaluating setting '".$key."'. ".
232-
'Returning the `defaultValue` parameter that you specified in '.
233-
"your application: '".Utils::getStringRepresentation($defaultValue)."'.";
231+
$message = "Error occurred in the `getValueDetails` method while evaluating setting '".$key."'. "
232+
.'Returning the `defaultValue` parameter that you specified in '
233+
."your application: '".Utils::getStringRepresentation($defaultValue)."'.";
234234
$messageCtx = [
235235
'event_id' => 1002, 'exception' => $exception,
236236
];
@@ -461,9 +461,9 @@ private function checkSettingsAvailable(SettingsResult $settingsResult, string $
461461
private function checkSettingAvailable(SettingsResult $settingsResult, string $key, mixed $defaultValue): ?string
462462
{
463463
if (!$settingsResult->hasConfigJson) {
464-
$message = "Config JSON is not present when evaluating setting '".$key."'. ".
465-
'Returning the `defaultValue` parameter that you specified in '.
466-
"your application: '".Utils::getStringRepresentation($defaultValue)."'.";
464+
$message = "Config JSON is not present when evaluating setting '".$key."'. "
465+
.'Returning the `defaultValue` parameter that you specified in '
466+
."your application: '".Utils::getStringRepresentation($defaultValue)."'.";
467467
$messageCtx = [
468468
'event_id' => 1000,
469469
];
@@ -473,10 +473,10 @@ private function checkSettingAvailable(SettingsResult $settingsResult, string $k
473473
}
474474

475475
if (!array_key_exists($key, $settingsResult->settings)) {
476-
$message = "Failed to evaluate setting '".$key."' (the key was not found in config JSON). ".
477-
'Returning the `defaultValue` parameter that you specified in your '.
478-
"application: '".Utils::getStringRepresentation($defaultValue)."'. ".
479-
'Available keys: ['.(!empty($settingsResult->settings) ? "'".implode("', '", array_keys($settingsResult->settings))."'" : '').'].';
476+
$message = "Failed to evaluate setting '".$key."' (the key was not found in config JSON). "
477+
.'Returning the `defaultValue` parameter that you specified in your '
478+
."application: '".Utils::getStringRepresentation($defaultValue)."'. "
479+
.'Available keys: ['.(!empty($settingsResult->settings) ? "'".implode("', '", array_keys($settingsResult->settings))."'" : '').'].';
480480
$messageCtx = [
481481
'event_id' => 1001,
482482
];

src/ConfigFetcher.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ private function executeFetch(?string $etag, string $url, int $executionCount):
114114

115115
if (RedirectMode::SHOULD == $redirect) {
116116
$this->logger->warning(
117-
'The `dataGovernance` parameter specified at the client initialization is '.
118-
'not in sync with the preferences on the ConfigCat Dashboard. '.
119-
'Read more: https://configcat.com/docs/advanced/data-governance/',
117+
'The `dataGovernance` parameter specified at the client initialization is '
118+
.'not in sync with the preferences on the ConfigCat Dashboard. '
119+
.'Read more: https://configcat.com/docs/advanced/data-governance/',
120120
[
121121
'event_id' => 3002,
122122
]
@@ -178,18 +178,18 @@ private function sendConfigFetchRequest(?string $etag, string $url): FetchRespon
178178
return FetchResponse::notModified();
179179
}
180180

181-
$message = 'Your SDK Key seems to be wrong. You can find the valid SDK Key at https://app.configcat.com/sdkkey. '.
182-
"Received unexpected response: {$statusCode}";
181+
$message = 'Your SDK Key seems to be wrong. You can find the valid SDK Key at https://app.configcat.com/sdkkey. '
182+
."Received unexpected response: {$statusCode}";
183183
$messageCtx = [
184184
'event_id' => 1100,
185185
];
186186
$this->logger->error($message, $messageCtx);
187187

188188
return FetchResponse::failure(InternalLogger::format($message, $messageCtx));
189189
} catch (ClientExceptionInterface $exception) {
190-
$message = 'Unexpected error occurred while trying to fetch config JSON. '.
191-
'It is most likely due to a local network issue. '.
192-
'Please make sure your application can reach the ConfigCat CDN servers (or your proxy server) over HTTP.';
190+
$message = 'Unexpected error occurred while trying to fetch config JSON. '
191+
.'It is most likely due to a local network issue. '
192+
.'Please make sure your application can reach the ConfigCat CDN servers (or your proxy server) over HTTP.';
193193
$messageCtx = ['event_id' => 1103, 'exception' => $exception];
194194
$this->logger->error($message, $messageCtx);
195195

src/RolloutEvaluator.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,44 +1181,44 @@ private function getUserAttributeValueAsStringArray(string $attributeName, mixed
11811181

11821182
private function logUserObjectIsMissing(string $key): void
11831183
{
1184-
$this->logger->warning("Cannot evaluate targeting rules and % options for setting '{$key}' (User Object is missing). ".
1185-
'You should pass a User Object to the evaluation methods like `getValue()` in order to make targeting work properly. '.
1186-
'Read more: https://configcat.com/docs/advanced/user-object/', [
1184+
$this->logger->warning("Cannot evaluate targeting rules and % options for setting '{$key}' (User Object is missing). "
1185+
.'You should pass a User Object to the evaluation methods like `getValue()` in order to make targeting work properly. '
1186+
.'Read more: https://configcat.com/docs/advanced/user-object/', [
11871187
'event_id' => 3001,
11881188
]);
11891189
}
11901190

11911191
private function logUserObjectAttributeIsMissingPercentage(string $key, string $attributeName): void
11921192
{
1193-
$this->logger->warning("Cannot evaluate % options for setting '{$key}' (the User.{$attributeName} attribute is missing). ".
1194-
"You should set the User.{$attributeName} attribute in order to make targeting work properly. ".
1195-
'Read more: https://configcat.com/docs/advanced/user-object/', [
1193+
$this->logger->warning("Cannot evaluate % options for setting '{$key}' (the User.{$attributeName} attribute is missing). "
1194+
."You should set the User.{$attributeName} attribute in order to make targeting work properly. "
1195+
.'Read more: https://configcat.com/docs/advanced/user-object/', [
11961196
'event_id' => 3003,
11971197
]);
11981198
}
11991199

12001200
private function logUserObjectAttributeIsMissingCondition(string $condition, string $key, string $attributeName): void
12011201
{
1202-
$this->logger->warning("Cannot evaluate condition ({$condition}) for setting '{$key}' (the User.{$attributeName} attribute is missing). ".
1203-
"You should set the User.{$attributeName} attribute in order to make targeting work properly. ".
1204-
'Read more: https://configcat.com/docs/advanced/user-object/', [
1202+
$this->logger->warning("Cannot evaluate condition ({$condition}) for setting '{$key}' (the User.{$attributeName} attribute is missing). "
1203+
."You should set the User.{$attributeName} attribute in order to make targeting work properly. "
1204+
.'Read more: https://configcat.com/docs/advanced/user-object/', [
12051205
'event_id' => 3003,
12061206
]);
12071207
}
12081208

12091209
private function logUserObjectAttributeIsInvalid(string $condition, string $key, string $reason, string $attributeName): void
12101210
{
1211-
$this->logger->warning("Cannot evaluate condition ({$condition}) for setting '{$key}' ({$reason}). ".
1212-
"Please check the User.{$attributeName} attribute and make sure that its value corresponds to the comparison operator.", [
1211+
$this->logger->warning("Cannot evaluate condition ({$condition}) for setting '{$key}' ({$reason}). "
1212+
."Please check the User.{$attributeName} attribute and make sure that its value corresponds to the comparison operator.", [
12131213
'event_id' => 3004,
12141214
]);
12151215
}
12161216

12171217
private function logUserObjectAttributeIsAutoConverted(string $condition, string $key, string $attributeName, string $attributeValue): void
12181218
{
1219-
$this->logger->warning("Evaluation of condition ({$condition}) for setting '{$key}' may not produce the expected result ".
1220-
"(the User.{$attributeName} attribute is not a string value, thus it was automatically converted to the string value '{$attributeValue}'). ".
1221-
'Please make sure that using a non-string value was intended.', [
1219+
$this->logger->warning("Evaluation of condition ({$condition}) for setting '{$key}' may not produce the expected result "
1220+
."(the User.{$attributeName} attribute is not a string value, thus it was automatically converted to the string value '{$attributeValue}'). "
1221+
.'Please make sure that using a non-string value was intended.', [
12221222
'event_id' => 3005,
12231223
]);
12241224
}
@@ -1255,9 +1255,9 @@ private function checkDefaultValueTypeMismatch(mixed $returnValue, mixed $defaul
12551255
$settingTypeName = $settingType->name;
12561256
$defaultValueType = gettype($defaultValue);
12571257

1258-
$this->logger->warning("The type of a setting does not match the type of the specified default value ({$defaultValue}). ".
1259-
"Setting's type was {$settingTypeName} but the default value's type was {$defaultValueType}. ".
1260-
"Please make sure that using a default value not matching the setting's type was intended.", [
1258+
$this->logger->warning("The type of a setting does not match the type of the specified default value ({$defaultValue}). "
1259+
."Setting's type was {$settingTypeName} but the default value's type was {$defaultValueType}. "
1260+
."Please make sure that using a default value not matching the setting's type was intended.", [
12611261
'event_id' => 4002,
12621262
]);
12631263
}

tests/ConfigCatClientTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,24 @@ public function testConstructCacheRefreshIntervalOption()
9494
$this->assertSame(20, $propInterval);
9595
}
9696

97+
/**
98+
* @dataProvider provideTestDataForSdkKeyFormat_ShouldBeValidated
99+
*/
100+
public function testSdkKeyFormatShouldBeValidated(string $sdkKey, bool $customBaseUrl, bool $isValid)
101+
{
102+
$clientOptions = $customBaseUrl
103+
? [ClientOptions::BASE_URL => 'https://my-configcat-proxy']
104+
: [];
105+
106+
if (!$isValid) {
107+
$this->expectException(InvalidArgumentException::class);
108+
} else {
109+
$this->expectNotToPerformAssertions();
110+
}
111+
112+
$client = new ConfigCatClient($sdkKey, $clientOptions);
113+
}
114+
97115
public function provideTestDataForSdkKeyFormat_ShouldBeValidated()
98116
{
99117
return Utils::withDescription([
@@ -119,24 +137,6 @@ public function provideTestDataForSdkKeyFormat_ShouldBeValidated()
119137
});
120138
}
121139

122-
/**
123-
* @dataProvider provideTestDataForSdkKeyFormat_ShouldBeValidated
124-
*/
125-
public function testSdkKeyFormatShouldBeValidated(string $sdkKey, bool $customBaseUrl, bool $isValid)
126-
{
127-
$clientOptions = $customBaseUrl
128-
? [ClientOptions::BASE_URL => 'https://my-configcat-proxy']
129-
: [];
130-
131-
if (!$isValid) {
132-
$this->expectException(InvalidArgumentException::class);
133-
} else {
134-
$this->expectNotToPerformAssertions();
135-
}
136-
137-
$client = new ConfigCatClient($sdkKey, $clientOptions);
138-
}
139-
140140
public function testGetValueFailedFetch()
141141
{
142142
$client = new ConfigCatClient('testGetValueFailedFetc/h-34567890123456789012', [ClientOptions::FETCH_CLIENT => GuzzleFetchClient::create([

0 commit comments

Comments
 (0)