Skip to content

Commit 7fd19f8

Browse files
authored
Modernize currency API (#123)
Modernizes `php-currency-api` for v2 with a stricter PHP 8.3+ baseline, PSR HTTP abstractions, precise decimal math, updated provider support, and a refreshed test/tooling/docs surface. - Require PHP 8.3+ and add strict types throughout. - Replace hard-wired Guzzle usage with PSR-18 client and PSR-17 request factory support. - Add `Currency` backed enum while keeping `Symbol` as a deprecation shim. - Switch conversion rates from floats to `brick/math` `BigDecimal`. - Add new built-in drivers: - `frankfurter` - `currencyapi` - `fastforex` - Rewrite `exchangeratesapi` for APILayer’s current endpoint and implement conversion support. - Add instance-based `DriverFactory` registration while preserving `DriverFactory::make()`. - Add modern CI/tooling: - GitHub Actions - Pint - PHPStan - Rector - PHPUnit 12 - Refresh README, Changelog, contributor docs, upgrade notes, and examples.
1 parent 3e58c13 commit 7fd19f8

71 files changed

Lines changed: 6619 additions & 3741 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codeclimate.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.editorconfig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@ root = true
66
# Unix-style newlines with a newline ending every file
77
[*]
88
indent_style = space
9-
indent_size = 2
9+
indent_size = 4
1010
end_of_line = lf
1111
insert_final_newline = true
1212
trim_trailing_whitespace = true
1313
charset = utf-8
1414

1515
[*.md]
16-
indent_size = 4
16+
indent_size = 1
17+
18+
[*.php]
19+
indent_size = 1
20+
21+
[*.toml]
22+
indent_size = 2
23+
24+
[*.{yml,yaml,json,neon}]
25+
indent_size = 2

.github/dependabot.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
---
12
version: 2
23
updates:
3-
- package-ecosystem: composer
4-
directory: "/"
5-
schedule:
6-
interval: daily
7-
time: "04:00"
8-
open-pull-requests-limit: 10
9-
reviewers:
10-
- otherguy
11-
assignees:
12-
- otherguy
13-
labels:
14-
- "dependabot \U0001F916"
4+
- package-ecosystem: composer
5+
directory: /
6+
schedule:
7+
interval: weekly
8+
open-pull-requests-limit: 10
9+
labels: [dependencies]
10+
- package-ecosystem: github-actions
11+
directory: /
12+
schedule:
13+
interval: weekly
14+
open-pull-requests-limit: 5
15+
labels: [dependencies, github-actions]

.github/reaction.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/stale.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
name: CI
3+
'on':
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
permissions:
9+
contents: read
10+
jobs:
11+
lint:
12+
name: Lint
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
17+
with:
18+
persist-credentials: false
19+
- name: Markdown Lint
20+
uses: DavidAnson/markdownlint-cli2-action@v23
21+
with:
22+
globs: |
23+
**/*.md
24+
config: ".markdownlint.yaml"
25+
26+
- name: YAML Lint
27+
uses: karancode/yamllint-github-action@master
28+
with:
29+
yamllint_config_filepath: .yamllint.yml
30+
yamllint_comment: true
31+
env:
32+
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
test:
34+
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
35+
needs: lint
36+
runs-on: ${{ matrix.os }}
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
os: [ubuntu-latest]
41+
php: ['8.3', '8.4']
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
45+
with:
46+
persist-credentials: false
47+
- name: Setup PHP
48+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f
49+
with:
50+
php-version: ${{ matrix.php }}
51+
extensions: json, mbstring
52+
coverage: ${{ matrix.php == '8.3' && 'pcov' || 'none' }}
53+
tools: composer:v2
54+
- name: Cache Composer dependencies
55+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
56+
with:
57+
path: ~/.composer/cache
58+
key: composer-${{ matrix.php }}-${{ hashFiles('composer.json') }}
59+
restore-keys: composer-${{ matrix.php }}-
60+
- name: Install dependencies
61+
run: composer install --prefer-dist --no-interaction --no-progress
62+
- name: Lint (Pint)
63+
run: vendor/bin/pint --test
64+
- name: Static analysis (PHPStan)
65+
run: vendor/bin/phpstan analyse --no-progress
66+
- name: Rector dry-run
67+
run: vendor/bin/rector --dry-run
68+
- name: Run tests
69+
run: |
70+
mkdir -p build
71+
if [ "${{ matrix.php }}" = "8.3" ]; then
72+
XDEBUG_MODE=coverage vendor/bin/phpunit
73+
else
74+
vendor/bin/phpunit --no-coverage
75+
fi
76+
- name: Upload coverage to Coveralls
77+
if: matrix.php == '8.3'
78+
env:
79+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
80+
run: |-
81+
if [ -n "$COVERALLS_REPO_TOKEN" ]; then
82+
vendor/bin/php-coveralls --coverage_clover build/cov.xml --json_path build/coverage.json -v
83+
else
84+
echo "Skipping Coveralls upload — COVERALLS_REPO_TOKEN not set."
85+
fi

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
### VisualStudioCode template
22
.vscode/*
3-
!.vscode/settings.json
43
!.vscode/tasks.json
54
!.vscode/launch.json
65
!.vscode/extensions.json
76

7+
### Local environment
8+
.env
9+
810
### Composer template
911
composer.phar
1012
/vendor/
@@ -15,3 +17,8 @@ composer.phar
1517
### PHPUnit
1618
build
1719
.phpunit.result.cache
20+
21+
### Local agent/tooling scratch
22+
.code-review-graph/
23+
.docs/
24+
tasks/

0 commit comments

Comments
 (0)