<?php

/**
 * Interface for classes that can be both serialized and unserialized to/from JSON.
 *
 * Should generally be used together with Northmill_Online_Shared\Traits\Json_Decode_Trait.
 *
 * @package northmill-online-shared
 */
declare (strict_types=1);
namespace Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Interfaces;

use JsonSerializable;
defined('ABSPATH') || exit;
/**
 * Interface JsonUnserializable
 *
 * @used Northmill Sync
 * @used Northmill Checkout
 */
interface JsonUnserializable extends JsonSerializable
{
    /**
     * Takes a JSON string matching what is returned by jsonSerialize() and returns an instance of the class.
     *
     * @param string|array $data JSON data. This is either a JSON string or an already decoded array.
     *
     * @return static|null The instance of the class, or null if the data is invalid.
     *
     * @used Northmill Sync
     */
    public static function jsonUnserialize(string|array $data): ?static;
}
