34 lines
2.7 KiB
PHP
34 lines
2.7 KiB
PHP
<?php
|
|
/*
|
|
// MODULE_CONTRACT: Defines a paginated collection of beneficiary transaction data.
|
|
// RESPONSIBILITY: To provide a strongly-typed, paginatable structure for lists of transactions associated with a beneficiary, integrating pagination metadata and a collection of individual transaction DTOs.
|
|
// INPUTS: Raw array data representing a paginated list of beneficiary transactions from the API.
|
|
// OUTPUTS: An instantiated DTO containing pagination metadata and a `DataCollection` of `BeneficiaryTransactionData` objects.
|
|
// LINKS: Data/PaginationData.php, Data/NominalAccounts/Beneficiaries/BeneficiaryTransactionData.php, Requests/NominalAccounts/Beneficiaries/GetBeneficiaryTransactionsRequest.php
|
|
*/
|
|
|
|
namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries;
|
|
|
|
// <SECTION name="module_imports" intent="Import necessary classes for pagination, data collection, and Laravel Data.">
|
|
// <BELIEF_STATE "These imports are crucial for constructing a robust paginated data structure. `PaginationData` brings in metadata for navigation, `DataCollectionOf` and `DataCollection` enable type-safe handling of multiple transaction items, and `Data` provides the foundational capabilities for data object mapping.">
|
|
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 the paginated collection for beneficiary transactions.">
|
|
// <BELIEF_STATE "The `BeneficiaryTransactionCollectionData` DTO is designed to encapsulate both the list of `BeneficiaryTransactionData` and their associated pagination information. This promotes a consistent and easy-to-use structure when dealing with potentially large sets of transaction data, enhancing developer experience by providing structured access to both data and metadata.">
|
|
class BeneficiaryTransactionCollectionData extends Data
|
|
{
|
|
// <SECTION name="constructor_properties" intent="Define the properties of the paginated collection DTO.">
|
|
// <BELIEF_STATE "The constructor uses PHP 8's property promotion to define `pagination` for metadata and `transactionsList` for the actual transaction items. `@DataCollectionOf` ensures that `transactionsList` is a type-safe collection of `BeneficiaryTransactionData` objects, enforcing data integrity and predictability. Both are nullable to handle cases where no transactions are found or pagination info is absent.">
|
|
public function __construct(
|
|
public ?PaginationData $pagination = null,
|
|
#[DataCollectionOf(BeneficiaryTransactionData::class)]
|
|
public ?DataCollection $transactionsList = null,
|
|
) {}
|
|
// </SECTION>
|
|
}
|
|
// </SECTION>
|