rob-revisited/ide/tests/fixtures/doctrine-expected/PostInput.php

35 lines
693 B
PHP

<?php
namespace App\Dto;
use App\Entity\Post;
use App\Enum\Status;
use Symfony\Component\Validator\Constraints as Assert;
/**
* What a client sends to create or change a Post.
*
* @see Post
*/
final class PostInput
{
public function __construct(
#[Assert\NotBlank]
#[Assert\Length(max: 255)]
public string $title,
#[Assert\NotNull]
public Status $status,
public ?int $id = null,
public ?string $price = null,
) {
}
public function applyTo(Post $post): Post
{
$post->setTitle($this->title);
$post->setPrice($this->price);
$post->setStatus($this->status);
return $post;
}
}