HEX
Server: LiteSpeed
System: Linux server315.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: globfdxw (6114)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //home/globfdxw/www/wp-content/plugins/give/src/DonationForms/V2/Properties/DonationFormLevel.php
<?php

namespace Give\DonationForms\V2\Properties;

use Give\Framework\Support\ValueObjects\Money;

final class DonationFormLevel
{
    /**
     * @var int
     */
    public $id;
    /**
     * @var Money
     */
    public $amount;
    /**
     * @var string
     */
    public $label;
    /**
     * @var bool
     */
    public $isDefault;

    /**
     * @since 2.24.0
     *
     * @param array $array
     *
     * @return DonationFormLevel
     */
    public static function fromArray(array $array): DonationFormLevel
    {
        $self = new static();

        $self->id = $array['_give_id']['level_id'];
        $self->amount = Money::fromDecimal($array['_give_amount'], give_get_currency());
        $self->label = $array['_give_text'] ?? '';
        $self->isDefault = isset($array['_give_default']) && $array['_give_default'] === 'default';

        return $self;
    }

    /**
     * @since 2.24.0
     *
     * @param string $price
     *
     * @return DonationFormLevel
     */
    public static function fromPrice(string $price): DonationFormLevel
    {
        $self = new static();

        $self->id = 0;
        $self->amount = Money::fromDecimal($price, give_get_currency());
        $self->label = '';
        $self->isDefault = true;

        return $self;
    }
}