Skip to content

Commit 261c313

Browse files
zhukaihantyiuhc
andauthored
feat: autoload files (#43)
Co-authored-by: Tim Yiu <[email protected]>
1 parent bf771e0 commit 261c313

17 files changed

+47
-59
lines changed

composer.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@
3636
"autoload": {
3737
"psr-4": {
3838
"AmplitudeExperiment\\": "src/"
39-
}
39+
},
40+
"files": [
41+
"src/Version.php",
42+
"src/Util.php",
43+
"src/EvaluationCore/Util.php",
44+
"src/Flag/Util.php",
45+
"src/Assignment/AssignmentConstants.php",
46+
"src/Http/GuzzleConstants.php"
47+
]
4048
},
4149
"autoload-dev": {
4250
"psr-4": {

src/AmplitudeCookie.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
use AmplitudeExperiment\Logger\LogLevel;
88
use Exception;
99

10-
require_once __DIR__ . '/Util.php';
11-
1210
class AmplitudeCookie
1311
{
1412
/**

src/Assignment/Assignment.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
use RuntimeException;
99
use function AmplitudeExperiment\hashCode;
1010

11-
require_once __DIR__ . '/../Util.php';
12-
require_once __DIR__ . '/AssignmentService.php';
13-
1411
/**
1512
* Event class for tracking assignments to Amplitude Experiment.
1613
*/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
namespace AmplitudeExperiment\Assignment;
4+
5+
const FLAG_TYPE_MUTUAL_EXCLUSION_GROUP = 'mutual-exclusion-group';
6+
const DAY_MILLIS = 24 * 60 * 60 * 1000;

src/Assignment/AssignmentService.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
use AmplitudeExperiment\User;
66
use AmplitudeExperiment\Variant;
77

8-
require_once __DIR__ . '/../Util.php';
9-
10-
const FLAG_TYPE_MUTUAL_EXCLUSION_GROUP = 'mutual-exclusion-group';
11-
const DAY_MILLIS = 24 * 60 * 60 * 1000;
12-
138
class AssignmentService
149
{
1510
private AssignmentTrackingProvider $assignmentTrackingProvider;

src/Assignment/DefaultAssignmentFilter.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

33
namespace AmplitudeExperiment\Assignment;
4-
require_once __DIR__ . '/AssignmentService.php';
54

65
use Psr\Cache\CacheItemPoolInterface;
76
use Psr\Cache\InvalidArgumentException;

src/EvaluationCore/EvaluationEngine.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
use AmplitudeExperiment\EvaluationCore\Types\EvaluationCondition;
99
use Exception;
1010

11-
require_once __DIR__ . '/Util.php';
12-
1311
class EvaluationEngine
1412
{
1513
/**

src/Flag/FlagConfigFetcher.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
use Psr\Log\LoggerInterface;
99
use const AmplitudeExperiment\VERSION;
1010

11-
require_once __DIR__ . '/../Version.php';
12-
1311
class FlagConfigFetcher
1412
{
1513
private LoggerInterface $logger;

src/Flag/FlagConfigService.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
use Psr\Http\Client\ClientExceptionInterface;
88
use Psr\Log\LoggerInterface;
99

10-
require_once __DIR__ . '/Util.php';
11-
1210
class FlagConfigService
1311
{
1412
private LoggerInterface $logger;

src/Http/GuzzleConstants.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace AmplitudeExperiment\Http;
4+
5+
const GUZZLE_DEFAULTS = [
6+
/**
7+
* The request socket timeout, in milliseconds.
8+
*/
9+
'timeoutMillis' => 10000,
10+
/**
11+
* The number of retries to attempt before failing
12+
*/
13+
'retries' => 8,
14+
/**
15+
* Retry backoff minimum (starting backoff delay) in milliseconds. The minimum backoff is scaled by
16+
* `retryBackoffScalar` after each retry failure.
17+
*/
18+
'retryBackoffMinMillis' => 500,
19+
/**
20+
* Retry backoff maximum in milliseconds. If the scaled backoff is greater than the max, the max is
21+
* used for all subsequent retries.
22+
*/
23+
'retryBackoffMaxMillis' => 10000,
24+
/**
25+
* Scales the minimum backoff exponentially.
26+
*/
27+
'retryBackoffScalar' => 1.5,
28+
/**
29+
* The request timeout for retrying fetch requests.
30+
*/
31+
'retryTimeoutMillis' => 10000
32+
];

0 commit comments

Comments
 (0)