Skip to content

Commit 2d2bcba

Browse files
authored
Release/2.2.0 (#12)
1 parent 98fad31 commit 2d2bcba

File tree

6 files changed

+51
-52
lines changed

6 files changed

+51
-52
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,49 @@
11
name: CI
22

33
on:
4-
push:
54
pull_request:
65

76
permissions:
87
contents: read
98

9+
env:
10+
PHP_VERSION: '8.3'
11+
1012
jobs:
1113
auto-review:
1214
name: Auto review
1315
runs-on: ubuntu-latest
1416

1517
steps:
1618
- name: Checkout
17-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
1820

19-
- name: Use PHP 8.2
21+
- name: Configure PHP
2022
uses: shivammathur/setup-php@v2
2123
with:
22-
php-version: '8.2'
24+
php-version: ${{ env.PHP_VERSION }}
2325

2426
- name: Install dependencies
2527
run: composer update --no-progress --optimize-autoloader
2628

27-
- name: Run phpcs
28-
run: composer phpcs
29-
30-
- name: Run phpmd
31-
run: composer phpmd
29+
- name: Run review
30+
run: composer review
3231

3332
tests:
3433
name: Tests
3534
runs-on: ubuntu-latest
3635

3736
steps:
3837
- name: Checkout
39-
uses: actions/checkout@v3
38+
uses: actions/checkout@v4
4039

41-
- name: Use PHP 8.2
40+
- name: Use PHP ${{ env.PHP_VERSION }}
4241
uses: shivammathur/setup-php@v2
4342
with:
44-
php-version: '8.2'
43+
php-version: ${{ env.PHP_VERSION }}
4544

4645
- name: Install dependencies
4746
run: composer update --no-progress --optimize-autoloader
4847

49-
- name: Run unit tests
50-
env:
51-
XDEBUG_MODE: coverage
52-
run: composer test
53-
54-
- name: Run mutation tests
55-
run: composer test-mutation
48+
- name: Run tests
49+
run: composer tests

Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
DOCKER_RUN = docker run --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.2
1+
DOCKER_RUN = docker run --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.3
22

3-
.PHONY: configure test test-file test-no-coverage review show-reports clean
3+
.PHONY: configure test test-no-coverage review show-reports clean
44

55
configure:
66
@${DOCKER_RUN} composer update --optimize-autoloader
77

88
test:
99
@${DOCKER_RUN} composer tests
1010

11-
test-file:
12-
@${DOCKER_RUN} composer tests-file-no-coverage ${FILE}
13-
1411
test-no-coverage:
1512
@${DOCKER_RUN} composer tests-no-coverage
1613

@@ -22,4 +19,4 @@ show-reports:
2219

2320
clean:
2421
@sudo chown -R ${USER}:${USER} ${PWD}
25-
@rm -rf report vendor .phpunit.cache
22+
@rm -rf report vendor .phpunit.cache .lock

composer.json

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"psr",
1212
"currency",
1313
"iso-4217",
14+
"currencies",
1415
"tiny-blocks",
1516
"value-object"
1617
],
@@ -41,35 +42,33 @@
4142
}
4243
},
4344
"require": {
44-
"php": "^8.2"
45+
"php": "^8.3"
4546
},
4647
"require-dev": {
4748
"phpmd/phpmd": "^2.15",
48-
"phpunit/phpunit": "^11",
4949
"phpstan/phpstan": "^1",
50-
"infection/infection": "^0.29",
51-
"squizlabs/php_codesniffer": "^3.10"
50+
"phpunit/phpunit": "^11",
51+
"infection/infection": "^0",
52+
"squizlabs/php_codesniffer": "^3.11"
5253
},
5354
"scripts": {
55+
"test": "phpunit --configuration phpunit.xml tests",
5456
"phpcs": "phpcs --standard=PSR12 --extensions=php ./src",
55-
"phpmd": "phpmd ./src text phpmd.xml --suffixes php --exclude /src/Currency.php --ignore-violations-on-exit",
57+
"phpmd": "phpmd ./src text phpmd.xml --suffixes php --ignore-violations-on-exit",
5658
"phpstan": "phpstan analyse -c phpstan.neon.dist --quiet --no-progress",
57-
"test": "phpunit --log-junit=report/coverage/junit.xml --coverage-xml=report/coverage/coverage-xml --coverage-html=report/coverage/coverage-html tests",
58-
"test-mutation": "infection --only-covered --logger-html=report/coverage/mutation-report.html --coverage=report/coverage --min-msi=100 --min-covered-msi=100 --threads=4",
59-
"test-no-coverage": "phpunit --no-coverage",
60-
"test-mutation-no-coverage": "infection --only-covered --min-msi=100 --threads=4",
59+
"mutation-test": "infection --only-covered --threads=max --logger-html=report/coverage/mutation-report.html --coverage=report/coverage",
60+
"test-no-coverage": "phpunit --configuration phpunit.xml --no-coverage tests",
6161
"review": [
6262
"@phpcs",
6363
"@phpmd",
6464
"@phpstan"
6565
],
6666
"tests": [
6767
"@test",
68-
"@test-mutation"
68+
"@mutation-test"
6969
],
7070
"tests-no-coverage": [
71-
"@test-no-coverage",
72-
"@test-mutation-no-coverage"
71+
"@test-no-coverage"
7372
]
7473
}
7574
}

infection.json.dist

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
{
2-
"timeout": 10,
3-
"testFramework": "phpunit",
2+
"logs": {
3+
"text": "report/infection/logs/infection-text.log",
4+
"summary": "report/infection/logs/infection-summary.log"
5+
},
46
"tmpDir": "report/infection/",
7+
"minMsi": 100,
8+
"timeout": 30,
59
"source": {
610
"directories": [
711
"src"
812
]
913
},
10-
"logs": {
11-
"text": "report/infection/logs/infection-text.log",
12-
"summary": "report/infection/logs/infection-summary.log"
14+
"phpUnit": {
15+
"configDir": "",
16+
"customPath": "./vendor/bin/phpunit"
1317
},
1418
"mutators": {
1519
"@default": true
1620
},
17-
"phpUnit": {
18-
"configDir": "",
19-
"customPath": "./vendor/bin/phpunit"
20-
}
21+
"minCoveredMsi": 100,
22+
"testFramework": "phpunit"
2123
}

phpunit.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
failOnRisky="true"
77
failOnWarning="true"
88
cacheDirectory=".phpunit.cache"
9+
executionOrder="random"
910
beStrictAboutOutputDuringTests="true">
1011

1112
<source>
@@ -22,14 +23,15 @@
2223

2324
<coverage>
2425
<report>
26+
<xml outputDirectory="report/coverage/coverage-xml"/>
27+
<html outputDirectory="report/coverage/coverage-html"/>
2528
<text outputFile="report/coverage.txt"/>
26-
<html outputDirectory="report/html/"/>
2729
<clover outputFile="report/coverage-clover.xml"/>
2830
</report>
2931
</coverage>
3032

3133
<logging>
32-
<junit outputFile="report/execution-result.xml"/>
34+
<junit outputFile="report/coverage/junit.xml"/>
3335
</logging>
3436

3537
</phpunit>

src/Currency.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,16 @@ enum Currency: string
182182
case ZMW = 'ZMW';
183183
case ZWL = 'ZWL';
184184

185-
private const FRACTION_DIGITS_TWO = 2;
186-
private const FRACTION_DIGITS_ZERO = 0;
187-
private const FRACTION_DIGITS_FOUR = 4;
188-
private const FRACTION_DIGITS_THREE = 3;
185+
private const int FRACTION_DIGITS_TWO = 2;
186+
private const int FRACTION_DIGITS_ZERO = 0;
187+
private const int FRACTION_DIGITS_FOUR = 4;
188+
private const int FRACTION_DIGITS_THREE = 3;
189189

190+
/**
191+
* Returns the number of decimal places for the current currency.
192+
*
193+
* @return int The number of decimal places.
194+
*/
190195
public function getFractionDigits(): int
191196
{
192197
return match ($this) {

0 commit comments

Comments
 (0)