Files
alfa-bank-sdk/src/Data/NominalAccounts/BeneficiaryCollectionData.php
2026-01-18 23:53:31 +03:00

36 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
/*
// MODULE_CONTRACT: Represents a paginated collection of BeneficiaryData objects.
// RESPONSIBILITY: To provide a structured, type-safe container for lists of beneficiaries 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 `BeneficiaryData`.
// LINKS: Requests/NominalAccounts/Beneficiaries/GetBeneficiariesRequest.php
*/
namespace Apoloz\AlfaBank\Data\NominalAccounts;
// <SECTION name="module_imports" intent="Import necessary DTOs and Spatie Laravel Data components.">
// <BELIEF_STATE "This collection DTO relies on `PaginationData` for metadata and `BeneficiaryData` 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 beneficiaries.">
// <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.">
class BeneficiaryCollectionData extends Data
{
// <SECTION name="constructor_properties" intent="Define the properties of the beneficiary collection.">
// <BELIEF_STATE "The collection structure includes pagination metadata (`pagination`), the associated `accountNumber`, and the actual list of beneficiaries (`beneficiaries`). The `#[DataCollectionOf(BeneficiaryData::class)]` attribute is crucial for ensuring that each item in the `beneficiaries` array is automatically cast to a `BeneficiaryData` DTO.">
public function __construct(
public PaginationData $pagination,
public string $accountNumber,
#[DataCollectionOf(BeneficiaryData::class)]
public DataCollection $beneficiaries
) {}
// </SECTION>
}