• File: BlockAttributes.php
  • Full Path: /home/bravrvjk/itiministry.org/wp-content/plugins/give/src/DonationForms/Blocks/DonationFormBlock/DataTransferObjects/BlockAttributes.php
  • Date Modified: 12/21/2023 2:33 AM
  • File size: 1.13 KB
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace Give\DonationForms\Blocks\DonationFormBlock\DataTransferObjects;

use Give\Framework\Support\Contracts\Arrayable;

class BlockAttributes implements Arrayable
{
    /**
     * @var int|null
     */
    public $formId;
    /**
     * @var string
     */
    public $blockId;

    /**
     * @var string
     */
    public $formFormat;

    /**
     * @var string
     */
    public $openFormButton;

    /**
     * @since 3.2.2 add v3 default for form button.
     * @since 3.0.0
     */
    public static function fromArray(array $array): BlockAttributes
    {
        $self = new self();

        $self->formId = !empty($array['formId']) ? (int)$array['formId'] : null;
        $self->blockId = !empty($array['blockId']) ? (string)$array['blockId'] : null;
        $self->formFormat = !empty($array['formFormat']) ? (string)$array['formFormat'] : null;
        $self->openFormButton = !empty($array['openFormButton']) ? (string)$array['openFormButton'] : __('Donate now', 'give');

        return $self;
    }

    /**
     * @since 3.0.0
     */
    public function toArray(): array
    {
        return get_object_vars($this);
    }
}