<?php

declare(strict_types=1);

namespace App\Service\OnChange;

interface OnChangeInterface
{
    /**
     * Validate the new data, throw a RuntimeException if data is not valid.
     */
    public function validate(mixed $data, OnChangeContext $context): void;

    /**
     * Apply transformations to the new data before it to be persisted.
     */
    public function preProcess(mixed $data, OnChangeContext $context): mixed;

    /**
     * Other operations to run before the data to be persisted.
     */
    public function beforeChange(mixed $data, OnChangeContext $context): void;

    /**
     * Operations to run after the data has been persisted.
     */
    public function onChange(mixed $data, OnChangeContext $context): void;
}
