<?php

declare(strict_types=1);

namespace App\DataTransferObjects;

final readonly class PartnerInvestmentData
{
    public function __construct(
        public int $partnerId,
        public int $investmentPropertyId,
        public int $sharesPurchased,
        public float $totalInvestment,
        public string $status = 'active',
    ) {}

    /**
     * Create from array
     *
     * @param  array<string, mixed>  $data
     */
    public static function fromArray(array $data): self
    {
        return new self(
            partnerId: (int) $data['partner_id'],
            investmentPropertyId: (int) $data['investment_property_id'],
            sharesPurchased: (int) $data['shares_purchased'],
            totalInvestment: (float) $data['total_investment'],
            status: $data['status'] ?? 'active',
        );
    }

    /**
     * Convert to array for model creation
     *
     * @return array<string, mixed>
     */
    public function toArray(): array
    {
        return [
            'partner_id' => $this->partnerId,
            'investment_property_id' => $this->investmentPropertyId,
            'shares_purchased' => $this->sharesPurchased,
            'total_investment' => $this->totalInvestment,
            'status' => $this->status,
        ];
    }
}
