<?php

namespace Sibs\Stargate\Dto;

class AmountDto extends AbstractDto
{
    /** @var string */
    public $currency;

    /** @var float */
    public $value;

    /**
     * Constructor.
     */
    public function __construct(string $currency, float $value)
    {
        $this->currency = $currency;
        $this->value = $value;
    }

    /**
     * From Array.
     */
    public static function fromArray(array $data): self
    {
        return new self(
            $data['currency'] ?? '',
            (float) ($data['value'] ?? 0)
        );
    }
}
