ldc-boutique-cnc-sable/app/Dto/ArcadiaIncoPreviewDto.php

63 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Dto;
final readonly class ArcadiaIncoPreviewDto implements \JsonSerializable
{
public function __construct(
public int $noArt,
public string $name,
public string $libelle,
public ?string $brand,
public ?string $nutriscore,
public ?string $servings,
public ?string $allergens,
public ?string $ingredients = null,
public ?string $preparation = null,
public ?float $energyKcal = null,
public ?float $energyKj = null,
public ?float $fat = null,
public ?float $satFat = null,
public ?float $carbs = null,
public ?float $sugar = null,
public ?float $fiber = null,
public ?float $protein = null,
public ?float $salt = null,
) {
}
/**
* @return array<string, mixed>
*/
public function toArray(): array
{
return [
'no_art' => $this->noArt,
'name' => $this->name,
'libelle' => $this->libelle,
'brand' => $this->brand,
'nutriscore' => $this->nutriscore,
'servings' => $this->servings,
'allergens' => $this->allergens,
'ingredients' => $this->ingredients,
'preparation' => $this->preparation,
'energy_kcal' => $this->energyKcal,
'energy_kj' => $this->energyKj,
'fat' => $this->fat,
'sat_fat' => $this->satFat,
'carbs' => $this->carbs,
'sugar' => $this->sugar,
'fiber' => $this->fiber,
'protein' => $this->protein,
'salt' => $this->salt,
];
}
#[\Override]
public function jsonSerialize(): mixed
{
return $this->toArray();
}
}