• File: TransferOptions.php
  • Full Path: /home/bravrvjk/itiministry.org/wp-content/plugins/give/src/FormMigration/DataTransferObjects/TransferOptions.php
  • Date Modified: 10/16/2023 9:55 PM
  • File size: 621 bytes
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace Give\FormMigration\DataTransferObjects;

use WP_REST_Request;

class TransferOptions
{
    /** @var bool */
    protected $delete;

    public function __construct(bool $delete)
    {
        $this->delete = $delete;
    }

    public static function fromRequest(WP_REST_Request $request): self
    {
        return new self(
            $request->get_param('delete')
        );
    }

    public static function fromArray($options): self
    {
        return new self(
            $options['delete']
        );
    }

    public function shouldDelete(): bool
    {
        return $this->delete;
    }
}