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

34 lines
720 B
PHP

<?php
namespace App\Dto;
use App\Entity\Post;
use App\Enum\Status;
/**
* A Post as the application shows it.
*
* @see Post
*/
final class PostOutput
{
public function __construct(
public readonly string $title,
public readonly Status $status,
public readonly ?int $id = null,
public readonly ?string $price = null,
public readonly ?int $author = null,
) {
}
public static function fromPost(Post $post): self
{
return new self(
id: $post->getId(),
title: $post->getTitle(),
price: $post->getPrice(),
status: $post->getStatus(),
author: $post->getAuthor()?->getId(),
);
}
}