forked from apoloz/alfa-bank-sdk
refactor(core): enhance SDK structure and documentation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
32
src/Data/Statement/TransactionCollectionData.php
Normal file
32
src/Data/Statement/TransactionCollectionData.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a paginated collection of TransactionData objects.
|
||||
// RESPONSIBILITY: To provide a structured, type-safe container for lists of account transactions returned by the API, including pagination metadata.
|
||||
// INPUTS: Raw JSON array from the API response.
|
||||
// OUTPUTS: An object containing pagination details and a collection of `TransactionData`.
|
||||
// LINKS: Requests/Statement/GetTransactionsRequest.php
|
||||
*/
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Statement;
|
||||
|
||||
// <SECTION name="module_imports" intent="Import necessary DTOs and Spatie Laravel Data components.">
|
||||
// <BELIEF_STATE "This collection DTO relies on `PaginationData` for metadata and `TransactionData` for the individual items. `DataCollection` and `DataCollectionOf` are Spatie Data features for handling typed arrays of DTOs.">
|
||||
use Apoloz\AlfaBank\Data\PaginationData;
|
||||
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\DataCollection;
|
||||
// </SECTION>
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a DTO for a collection of account transactions.">
|
||||
// <BELIEF_STATE "A dedicated DTO for a collection ensures that the structure of paginated lists is consistent and type-safe, providing a reliable contract for consumers to manage financial statements.">
|
||||
class TransactionCollectionData extends Data
|
||||
{
|
||||
// <SECTION name="constructor_properties" intent="Define the properties of the transaction collection.">
|
||||
// <BELIEF_STATE "The collection structure includes pagination metadata (`pagination`) and the actual list of transactions (`transactions`). The `#[DataCollectionOf(TransactionData::class)]` attribute is crucial for ensuring that each item in the `transactions` array is automatically cast to a `TransactionData` DTO.">
|
||||
public function __construct(
|
||||
public PaginationData $pagination,
|
||||
#[DataCollectionOf(TransactionData::class)]
|
||||
public DataCollection $transactions
|
||||
) {}
|
||||
// </SECTION>
|
||||
}
|
||||
Reference in New Issue
Block a user