tarlepp/symfony-flex-backend

View on GitHub
src/DTO/RestDtoInterface.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%
<?php
declare(strict_types = 1);
/**
 * /src/DTO/RestDtoInterface.php
 *
 * @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
 */

namespace App\DTO;

use App\Entity\Interfaces\EntityInterface;
use Throwable;

/**
 * @package App\DTO
 * @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
 */
interface RestDtoInterface
{
    public function setId(string $id): self;

    /**
     * Getter method for visited setters. This is needed for dto patching.
     *
     * @return array<int, string>
     */
    public function getVisited(): array;

    /**
     * Setter for visited data. This is needed for dto patching.
     */
    public function setVisited(string $property): self;

    /**
     * Method to load DTO data from specified entity.
     */
    public function load(EntityInterface $entity): self;

    /**
     * Method to update specified entity with DTO data.
     */
    public function update(EntityInterface $entity): EntityInterface;

    /**
     * Method to patch current dto with another one.
     *
     * @throws Throwable
     */
    public function patch(self $dto): self;
}