Skip to content

Commit

Permalink
feat: Use custom HTTP Client, custom Logger, PHPStan (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyiuhc authored Feb 5, 2024
1 parent 5d991a8 commit e33e12b
Show file tree
Hide file tree
Showing 42 changed files with 1,328 additions and 787 deletions.
37 changes: 21 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,43 @@ name: Test
on:
pull_request:
push:
branches: [ "main" ]

permissions:
contents: read
branches:
- main

jobs:
build:

runs-on: ubuntu-latest
test:
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
- name: Checkout
uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script test

- name: Run PHPStan
run: vendor/bin/phpstan analyse --ansi
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $user = \AmplitudeExperiment\User::builder()
->userProperties(['premium' => True])
->build();

$variants = $client->fetch($user)->wait();
$variants = $client->fetch($user);

// (3) Access a flag's variant
$variant = $variants['FLAG_KEY'] ?? null;
Expand All @@ -48,8 +48,8 @@ if ($variant) {
$experiment = new \AmplitudeExperiment\Experiment();
$client = $experiment->initializeLocal('<DEPLOYMENT_KEY>');

// (2) Start the local evaluation client.
$client->start()->wait();
// (2) Fetch latest flag configurations for the local evaluation client.
$client->refreshFlagConfigs();

// (3) Evaluate a user.
$user = \AmplitudeExperiment\User::builder()
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
"prefer-stable": true,
"require": {
"php": "^7.4 || ^8",
"lastguest/murmurhash": "^1",
"ext-json": "*",
"guzzlehttp/guzzle": "^7",
"monolog/monolog": "^2"
"psr/log": "^1 || ^2 || ^3"
},
"require-dev": {
"phpunit/phpunit": "9.*"
"phpunit/phpunit": "9.*",
"phpstan/phpstan": "^1"
},
"suggest": {
"monolog/monolog": "Allows more advanced logging of the application flow"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit e33e12b

Please sign in to comment.