SymfonyCasts/micro-mapper

Map to readonly class

HrjSnz opened this issue · 0 comments

HrjSnz commented

Hello,

i have question. Is possible somehow map to readonly class ? How i can see it use only setters after instance is created. But is there some feature or way how map it to constructor class for make it readonly ?

readonly class PaymentCreatedDto
{
    public function __construct(
        private string $paymentUrl,
        private string $paymentStatus,
    ) {
    }

    public function getPaymentUrl(): string
    {
        return $this->paymentUrl;
    }

    public function getPaymentStatus(): string
    {
        return $this->paymentStatus;
    }
}

Thanks !