Skip to content
Snippets Groups Projects
RestaurantMapper.php 1.47 KiB
Newer Older
<?php

namespace App\Mapper;

use App\Entity\Kitchen;
use App\Entity\Restaurant;
use App\Entity\RestaurantType;
use App\Model\File;
use App\Model\KitchenType;
use App\Model\RestaurantListingElement;
use App\Model\RestaurantType as RestaurantTypeModel;

class RestaurantMapper
{
    public static function mapToListElement(Restaurant $restaurant): RestaurantListingElement
    {
        return new RestaurantListingElement(
            $restaurant->getId(),
            $restaurant->getName(),
            $restaurant->getCode(),
            new RestaurantTypeModel(
                $restaurant->getTypeId()->getId(),
                $restaurant->getTypeId()->getName(),
                $restaurant->getTypeId()->getCode()
            ),
            $restaurant->getCheckInfo(),
            new File(
                1,
                "name",
                "description",
                10,
                "jpg",
                $restaurant->getPreviewImage()
            ),
            $restaurant->getSite()
        );
    }

    public static function mapToRestaurantType(RestaurantType $restaurantType): RestaurantTypeModel
    {
        return new RestaurantTypeModel(
            $restaurantType->getId(),
            $restaurantType->getName(),
            $restaurantType->getCode(),
        );
    }

    public static function mapToKitchenType(Kitchen $kitchen): KitchenType
    {
        return new KitchenType(
            $kitchen->getId(),
            $kitchen->getName()
        );
    }
}