Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
CreateInvestorAccountAction
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 __invoke
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace App\Action\Admin;
6
7use App\Domain\Account\Service\AccountService;
8use App\Renderer\JsonRenderer;
9use Psr\Http\Message\ResponseInterface;
10use Psr\Http\Message\ServerRequestInterface;
11
12final readonly class CreateInvestorAccountAction
13{
14    public function __construct(
15        private JsonRenderer $renderer,
16        private AccountService $accountService,
17    ) {}
18
19    /**
20     * @param ServerRequestInterface $request
21     * @param ResponseInterface $response
22     * @param array<string, string> $args
23     * @return ResponseInterface
24     */
25    public function __invoke(
26        ServerRequestInterface $request,
27        ResponseInterface $response,
28        array $args,
29    ): ResponseInterface {
30        $investorId = (int)$args['investorId'];
31
32        // Create the account
33        $account = $this->accountService->createAccountForInvestor($investorId);
34
35        return $this->renderer->json($response, [
36            'success' => true,
37            'message' => 'Investment account created successfully',
38            'data' => $account,
39        ], 201);
40    }
41}