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
ArchiveAdminFundAction
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\Funds\Service\FundsUpdater;
8use App\Renderer\JsonRenderer;
9use Psr\Http\Message\ResponseInterface;
10use Psr\Http\Message\ServerRequestInterface;
11
12/**
13 * Archive a fund (mark as Closed and unpublished).
14 *
15 * PATCH /api/admin/funds/{id}/archive
16 */
17final readonly class ArchiveAdminFundAction
18{
19    public function __construct(
20        private FundsUpdater $updater,
21        private JsonRenderer $renderer,
22    ) {}
23
24    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, array $args): ResponseInterface
25    {
26        $id = $args['id'] ?? '';
27
28        $fund = $this->updater->archiveFund($id);
29
30        return $this->renderer->json($response, [
31            'success' => true,
32            'message' => 'Fund archived',
33            'data' => $fund->toArray(),
34        ]);
35    }
36}