*/ final readonly class DiscountProductDto implements \JsonSerializable, Arrayable { public function __construct( public string $id, public string $name, public ?string $picture, ) { } public static function fromModel(Product $product): self { return new self( id: (string) $product->id, name: (string) $product->name, picture: publicS3Asset($product->picture), ); } /** * @return array{id: string, name: string, picture: ?string} */ #[\Override] public function toArray(): array { return [ 'id' => $this->id, 'name' => $this->name, 'picture' => $this->picture, ]; } /** * @return array{id: string, name: string, picture: ?string} */ #[\Override] public function jsonSerialize(): array { return $this->toArray(); } }