Skip to content

Commit fd15b48

Browse files
authored
#3 Refactoring to 2.2.x-dev
2 parents 8b2fa2c + b10b067 commit fd15b48

File tree

13 files changed

+105
-41
lines changed

13 files changed

+105
-41
lines changed

.github/workflows/main.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ jobs:
2020

2121
- name: Install composer dependencies
2222
run: |
23+
# Install code check tools
2324
composer run cs:install
24-
2525
# Install app dependencies
2626
composer install --no-interaction --prefer-dist
2727
28-
# Check code checker and coding standards
2928
- name: Check coding standards
3029
run: |
3130
composer run cs:check
@@ -37,7 +36,7 @@ jobs:
3736
runs-on: ubuntu-latest
3837
strategy:
3938
matrix:
40-
php: ['7.2', '7.3', '7.4'] # 8.0
39+
php: ['7.2', '7.3', '7.4', '8.0']
4140

4241
name: PHP ${{ matrix.php }} tests
4342
steps:
@@ -52,6 +51,9 @@ jobs:
5251

5352
- name: Install composer dependencies
5453
run: |
54+
# Remove unnecesery packages
55+
composer remove phpstan/phpstan phpstan/phpstan-nette --dev --no-interaction
56+
# Install app dependencies
5557
composer install --no-interaction --prefer-dist
5658
5759
- name: Run tests
@@ -65,3 +67,29 @@ jobs:
6567
flags: unittests
6668
name: codecov-umbrella
6769
fail_ci_if_error: true
70+
71+
benchmark:
72+
runs-on: ubuntu-latest
73+
strategy:
74+
matrix:
75+
php: ['7.4']
76+
77+
name: Benchmark on PHP ${{ matrix.php }}
78+
steps:
79+
- name: Git clone
80+
uses: actions/checkout@master
81+
82+
- name: Install PHP
83+
uses: shivammathur/setup-php@master
84+
with:
85+
php-version: ${{ matrix.php }}
86+
87+
- name: Install composer dependencies
88+
run: |
89+
# Install benchmarking tool
90+
composer global require phpbench/phpbench @dev
91+
# Install app dependencies
92+
composer install --no-interaction --prefer-dist
93+
94+
- name: Run benchmarks
95+
run: phpbench run

README.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
Robust PHP math integral solver
2-
===============================
1+
<h1 align="center">
2+
PHP Math Integral Solver
3+
</h1>
4+
5+
<p align="center">
6+
<a href="https://mathematicator.com" target="_blank">
7+
<img src="https://avatars3.githubusercontent.com/u/44620375?s=100&v=4">
8+
</a>
9+
</p>
310

411
[![Integrity check](https://github.com/mathematicator-core/integral-solver/workflows/Integrity%20check/badge.svg)](https://github.com/mathematicator-core/integral-solver/actions?query=workflow%3A%22Integrity+check%22)
512
[![codecov](https://codecov.io/gh/mathematicator-core/integral-solver/branch/master/graph/badge.svg)](https://codecov.io/gh/mathematicator-core/integral-solver)
13+
[![Latest Stable Version](https://poser.pugx.org/mathematicator-core/integral-solver/v/stable)](https://packagist.org/packages/mathematicator-core/integral-solver)
14+
[![Latest Unstable Version](https://poser.pugx.org/mathematicator-core/integral-solver/v/unstable)](https://packagist.org/packages/mathematicator-core/integral-solver)
615
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](./LICENSE)
16+
[![PHPStan Enabled](https://img.shields.io/badge/PHPStan-enabled%20L8-brightgreen.svg?style=flat)](https://phpstan.org/)
17+
18+
## Installation
19+
20+
```
21+
composer require mathematicator-core/calculator
22+
```
723

24+
## Usage
825
Get instance of `IntegralSolver` and compute:
926

1027
```php
@@ -127,8 +144,29 @@ one to the most abstract one:
127144
</tr>
128145
</table>
129146

130-
Contribution
131-
----
147+
**Third-party packages:**
148+
149+
⚠️ Not guaranteed!
150+
151+
<table>
152+
<tr>
153+
<td>
154+
<b>
155+
<a href="https://github.com/cothema/math-php-api">
156+
REST API
157+
</a>
158+
</b>
159+
</td>
160+
<td>
161+
Install the whole pack as a REST API service
162+
on your server (Docker ready) or
163+
access it via public cloud REST API.
164+
</td>
165+
</tr>
166+
</table>
167+
168+
169+
## Contribution
132170

133171
### Tests
134172

benchmarks/.gitkeep

Whitespace-only changes.

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
],
1919
"require": {
2020
"php": ">=7.2",
21-
"mathematicator-core/tokenizer": "^2.0@dev",
22-
"mathematicator-core/engine": "^2.0@dev",
23-
"mathematicator-core/numbers": "^2.0@dev"
21+
"mathematicator-core/tokenizer": "^2.2@dev",
22+
"mathematicator-core/engine": "^2.2@dev",
23+
"mathematicator-core/numbers": "^2.2@dev"
2424
},
2525
"require-dev": {
2626
"brainmaestro/composer-git-hooks": "dev-master",
@@ -47,12 +47,12 @@
4747
"composer create-project nette/coding-standard temp/coding-standard ^2 --no-progress"
4848
],
4949
"cs:check": [
50-
"php temp/code-checker/code-checker --short-arrays --strict-types --no-progress",
51-
"php temp/coding-standard/ecs check src --config temp/coding-standard/coding-standard-php71.yml"
50+
"php temp/code-checker/code-checker -d src -d tests -d benchmarks --short-arrays --strict-types --no-progress",
51+
"php temp/coding-standard/ecs check src tests benchmarks --config temp/coding-standard/coding-standard-php71.yml"
5252
],
5353
"cs:fix": [
54-
"php temp/code-checker/code-checker --short-arrays --strict-types --fix --no-progress",
55-
"php temp/coding-standard/ecs check src --config temp/coding-standard/coding-standard-php71.yml --fix"
54+
"php temp/code-checker/code-checker -d src -d tests -d benchmarks --short-arrays --strict-types --fix --no-progress",
55+
"php temp/coding-standard/ecs check src tests benchmarks --config temp/coding-standard/coding-standard-php71.yml --fix"
5656
],
5757
"phpstan": "vendor/bin/phpstan analyse src -c phpstan.neon --level 8 --no-progress",
5858
"fix": [
@@ -70,7 +70,7 @@
7070
},
7171
"extra": {
7272
"branch-alias": {
73-
"dev-master": "2.0.x-dev"
73+
"dev-master": "2.2.x-dev"
7474
},
7575
"hooks": {
7676
"post-merge": "composer install",

phpbench.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"bootstrap": "vendor/autoload.php",
3+
"path": "benchmarks"
4+
}

src/Exception/CanNotSolveException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Mathematicator\Integral\Exception;
66

77

8-
use Mathematicator\Engine\MathematicatorException;
8+
use Mathematicator\Engine\Exception\MathematicatorException;
99
use Mathematicator\Tokenizer\Token\IToken;
1010
use Mathematicator\Tokenizer\Token\SubToken;
1111

src/IntegralResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Mathematicator\Integral;
66

77

8-
use Mathematicator\Engine\Step;
8+
use Mathematicator\Engine\Step\Step;
99
use Mathematicator\Tokenizer\Token\IToken;
1010

1111
final class IntegralResult

src/IntegralSolver.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace Mathematicator\Integral;
66

77

8-
use Mathematicator\Engine\MathematicatorException;
8+
use Mathematicator\Engine\Exception\MathematicatorException;
99
use Mathematicator\Engine\QueryNormalizer;
10-
use Mathematicator\Engine\Step;
10+
use Mathematicator\Engine\Step\Step;
1111
use Mathematicator\Integral\Exception\CanNotSolveException;
12-
use Mathematicator\Integral\Rule\Rule;
12+
use Mathematicator\Integral\Rule\IRule;
1313
use Mathematicator\Integral\Solver\Solver;
1414
use Mathematicator\Tokenizer\Token\IToken;
1515
use Mathematicator\Tokenizer\Token\OperatorToken;
@@ -28,7 +28,7 @@
2828
class IntegralSolver
2929
{
3030

31-
/** @var Rule[] */
31+
/** @var IRule[] */
3232
public $rules = [];
3333

3434
/** @var Tokenizer */
@@ -135,10 +135,10 @@ public function processByTokens(array $tokens, ?string $differential = null): In
135135

136136

137137
/**
138-
* @param Rule $rule
138+
* @param IRule $rule
139139
* @return IntegralSolver
140140
*/
141-
public function addRule(Rule $rule): self
141+
public function addRule(IRule $rule): self
142142
{
143143
$this->rules[] = $rule;
144144

src/Rule/Rule.php renamed to src/Rule/IRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
namespace Mathematicator\Integral\Rule;
66

77

8-
interface Rule
8+
interface IRule
99
{
1010
}

src/Solver/Solver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Mathematicator\Integral\Solver;
66

77

8-
use Mathematicator\Engine\MathematicatorException;
8+
use Mathematicator\Engine\Exception\MathematicatorException;
99
use Mathematicator\Integral\Exception\CanNotSolveException;
1010
use Mathematicator\Tokenizer\Token\IToken;
1111
use Mathematicator\Tokenizer\Token\NumberToken;
@@ -40,14 +40,14 @@ private function solvePrimitiveIntegral(IToken $token): string
4040
{
4141
if ($token instanceof NumberToken) {
4242
if ($token->getToken() !== '0') {
43-
return ($num = $token->getNumber()->getHumanString()) === '1' ? 'x' : $num . 'x';
43+
return ($num = (string) $token->getNumber()) === '1' ? 'x' : $num . 'x';
4444
}
4545

4646
return '';
4747
}
4848

4949
if ($token instanceof VariableToken) {
50-
if (($times = $token->getTimes()->getHumanString()) === '1') {
50+
if (($times = (string) $token->getTimes()) === '1') {
5151
return '(x^2)/2';
5252
}
5353

0 commit comments

Comments
 (0)