Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
37.50% |
3 / 8 |
|
60.00% |
3 / 5 |
CRAP | |
0.00% |
0 / 1 |
Calculator | |
37.50% |
3 / 8 |
|
60.00% |
3 / 5 |
11.10 | |
0.00% |
0 / 1 |
add | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
multiply | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sum | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
squareRoot | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
expensiveBackgroundCalculation | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | namespace Apie\IntegrationTests\Apie\TypeDemo\Actions; |
3 | |
4 | use Apie\Core\Attributes\Context; |
5 | use Apie\Core\Attributes\Description; |
6 | use Apie\Core\Attributes\Route; |
7 | use Apie\Core\BackgroundProcess\SequentialBackgroundProcess; |
8 | use Apie\Core\Lists\ItemHashmap; |
9 | use Apie\Fixtures\BackgroundProcess\SequentialExample; |
10 | |
11 | final class Calculator |
12 | { |
13 | #[Route('/calc/{numberOne}/plus/{numberTwo}')] |
14 | public function add(#[Context()] float $numberOne, #[Context()] float $numberTwo): float |
15 | { |
16 | return $numberOne + $numberTwo; |
17 | } |
18 | |
19 | #[Route('/calc/{numberOne}/times/{numberTwo}')] |
20 | public function multiply(#[Context()] float $numberOne, #[Context()] float $numberTwo): float |
21 | { |
22 | return $numberOne * $numberTwo; |
23 | } |
24 | |
25 | public function sum(float... $numbers): float |
26 | { |
27 | return array_sum($numbers); |
28 | } |
29 | |
30 | public function squareRoot(float $numberOne): float |
31 | { |
32 | return sqrt($numberOne); |
33 | } |
34 | |
35 | #[Description('Runs an expensive background calculation')] |
36 | public function expensiveBackgroundCalculation(int $payload): SequentialBackgroundProcess |
37 | { |
38 | return new SequentialBackgroundProcess( |
39 | new SequentialExample(), |
40 | new ItemHashmap(['payload' => $payload]) |
41 | ); |
42 | } |
43 | } |