Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update phpunit to 10 #32

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tag_meged_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
tools: composer:v2

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
tools: composer:v2

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -63,12 +63,12 @@ jobs:
tools: composer:v2

- name: Set up Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '14.x'

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -126,25 +126,25 @@ jobs:
tools: composer:v2

- name: Set up Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '14.x'

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run Composer
run: composer install --no-interaction

- name: Update PHPUnit for Code Coverage
run: composer require phpunit/phpunit:^9.6 phploc/phploc:* sebastian/version:* --with-all-dependencies
run: composer require phpunit/phpunit:^10.5 sebastian/version:* --with-all-dependencies

- name: PHP Lint
run: ./vendor/bin/parallel-lint src tests examples

- name: Unit tests
run: |
mkdir -p build/logs
./vendor/bin/phpunit ./tests/ --coverage-clover build/logs/clover.xml
./vendor/bin/phpunit ./tests/ --coverage-clover build/logs/clover.xml --coverage-filter=./src/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/vendor/
composer.lock
.php-version
1 change: 0 additions & 1 deletion .php-version

This file was deleted.

24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,40 +149,47 @@ This class treats basic matters of primes.
// judge if all of $n are prime or not
$n = [ 2, 3, 5, ];
echo sprintf(
"Are all of [%s] prime? - %s.\n",
"Are all of [%s] prime? - %s.\n\n",
implode(', ', $n),
$p->isPrimeAll($n) ? 'Yes' : 'No'
);

// a prime previous to $n
$n = 5;
echo sprintf("A prime previous to %d is %d.\n", $n, $p->previous($n));

// a prime next to $n
$n = 5;
echo sprintf("A prime next to %d is %d.\n", $n, $p->next($n));
echo sprintf("A prime next to %d is %d.\n\n", $n, $p->next($n));

// primes between $a and $b
$a = 6;
$b = 14;
echo sprintf(
"Primes between %d and %d are [%s].\n",
"Primes between %d and %d are [%s].\n\n",
$a,
$b,
implode(', ', $p->between($a, $b))
);

// factorize
$n = 1234567890;
echo sprintf("Factorize %d:\n", $n);
echo sprintf("Factorize %d:\n\n", $n);

$r = $p->factorize($n);
$l1 = $p->numberOfDigits(max(array_column($r, 0)));
$l2 = $p->numberOfDigits(max(array_column($r, 1)));
$s = str_repeat(' ', $l1 + 1);
$b = $s . str_repeat('-', $l2);

foreach ($r as $f) {
echo (
$f[0]
? sprintf("%" . $l1 . "d)%" . $l2 . "d\n%s\n", $f[0], $f[1], $b)
: sprintf("%s%" . $l2 . "d\n", $s, $f[1])
);
}
echo "\n";

// Factorized formula
echo $n . " = " . $p->factorizedFormula($n)['formula'] . "\n";
Expand All @@ -193,9 +200,14 @@ This class treats basic matters of primes.
```
Is 3 prime? - Yes.
Are all of [2, 3, 5] prime? - Yes.

A prime previous to 5 is 3.
A prime next to 5 is 7.

Primes between 6 and 14 are [7, 11, 13].

Factorize 1234567890:

2)1234567890
----------
3) 617283945
Expand All @@ -207,6 +219,7 @@ This class treats basic matters of primes.
3607) 13717421
----------
3803

1234567890 = 2 * 3 ^ 2 * 5 * 3607 * 3803
```

Expand All @@ -216,6 +229,7 @@ This class treats basic matters of primes.
|:---|:---|
|`isPrime(int $n)`|judges if the param is prime or not|
|`isPrimeAll(array $elements)`|judges if all of the param are prime or not|
|`previous(int $n)`|returns a prime previous to the param|
|`next(int $n)`|returns a prime next to the param|
|`between(int $a, int $b)`|returns array of primes between the params|
|`factorize(int $n)`|factorize the param and returns the process as an array|
Expand Down Expand Up @@ -593,6 +607,6 @@ This class treats basic matters of Bezout's Identity.

*Document Created: 2023/10/19*

*Document Updated: 2024/03/16*
*Document Updated: 2024/04/17*

Copyright 2023 - 2024 macocci7
2 changes: 1 addition & 1 deletion bin/TestAndLint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test_and_lint() {
echo "-----------------------------------------------------------"
echo "[PHP $1][phpunit]"
./vendor/bin/phpunit ./tests/ \
--color auto
--color=auto
echo "-----------------------------------------------------------"
}

Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "macocci7/php-math-integer",
"version": "1.1.1",
"version": "1.1.2",
"description": "PHP Math Library of the subjects of number theory(only natural number).",
"type": "library",
"license": "MIT",
Expand All @@ -18,10 +18,9 @@
"minimum-stability": "stable",
"require-dev": {
"squizlabs/php_codesniffer": "^3.7",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^10.5",
"phpmd/phpmd": "^2.15",
"phpstan/phpstan": "^1.10",
"phploc/phploc": "^7.0",
"php-parallel-lint/php-parallel-lint": "^1.3"
}
}
Loading