Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| UpdateAdminFundPerformanceAction | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __invoke | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\Admin; |
| 6 | |
| 7 | use App\Domain\Admin\Service\AdminFundPerformanceService; |
| 8 | use App\Renderer\JsonRenderer; |
| 9 | use Psr\Http\Message\ResponseInterface; |
| 10 | use Psr\Http\Message\ServerRequestInterface; |
| 11 | |
| 12 | final readonly class UpdateAdminFundPerformanceAction |
| 13 | { |
| 14 | public function __construct( |
| 15 | private AdminFundPerformanceService $service, |
| 16 | private JsonRenderer $renderer, |
| 17 | ) {} |
| 18 | |
| 19 | /** |
| 20 | * @param array<string, string> $args |
| 21 | */ |
| 22 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, array $args): ResponseInterface |
| 23 | { |
| 24 | $fundId = (string)($args['fundId'] ?? ''); |
| 25 | $data = (array)$request->getParsedBody(); |
| 26 | |
| 27 | $year = (int)($data['year'] ?? 0); |
| 28 | $month = (int)($data['month'] ?? 0); |
| 29 | $returnPct = isset($data['returnPct']) ? (float)$data['returnPct'] : null; |
| 30 | $benchmarkPct = isset($data['benchmarkPct']) ? (float)$data['benchmarkPct'] : null; |
| 31 | $commentary = $data['commentary'] ?? null; |
| 32 | |
| 33 | $this->service->recordMonthlyPerformance($fundId, $year, $month, $returnPct, $benchmarkPct, $commentary); |
| 34 | |
| 35 | return $this->renderer->json($response, [ |
| 36 | 'success' => true, |
| 37 | 'message' => 'Performance data updated successfully', |
| 38 | ]); |
| 39 | } |
| 40 | } |