Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\Currencies\Domain\Repository;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use App\Modules\Currencies\Domain\Model\Currency;
12
13/**
14 * Currency Repository Contract.
15 */
16interface CurrencyRepositoryInterface
17{
18    /**
19     * @return list<Currency>
20     */
21    public function findAll(): array;
22
23    /**
24     * @return list<Currency>
25     */
26    public function findActive(): array;
27
28    public function findByCode(string $code): ?Currency;
29
30    public function findById(int $id): ?Currency;
31
32    public function save(Currency $currency): void;
33
34    /**
35     * Updates exchange rate and NBP metadata for currency by code.
36     */
37    public function updateRate(string $code, float $exchangeRate, ?string $tableNo, ?string $effectiveDate): void;
38
39    /**
40     * Deletes non-base currency by ID. Returns true on success, false if base or not found.
41     */
42    public function delete(int $id): bool;
43
44    /**
45     * Deletes non-base currency by 3-letter code. Returns true on success, false if base or not found.
46     */
47    public function deleteByCode(string $code): bool;
48
49    /**
50     * Records exchange rate snapshot into rate history table.
51     */
52    public function recordRateHistory(
53        string $code,
54        float $exchangeRate,
55        string $tableNo,
56        string $effectiveDate,
57        string $source = 'NBP'
58    ): void;
59
60    /**
61     * Retrieves historical exchange rates for specific currency.
62     *
63     * @return list<array<string, mixed>>
64     */
65    public function getRateHistory(string $code, int $limit = 30): array;
66
67    /**
68     * Retrieves all historical exchange rate entries ordered by effective date desc.
69     *
70     * @return list<array<string, mixed>>
71     */
72    public function getAllRateHistory(int $limit = 50): array;
73}