<?php

namespace common\logic\Product\ProductPointSale\Service;

use common\logic\AbstractBuilder;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Product\Product\Model\Product;
use common\logic\Product\ProductPointSale\Model\ProductPointSale;

class ProductPointSaleBuilder extends AbstractBuilder
{
    public function instanciateProductPointSale(): ProductPointSale
    {
        $productPointSale = new ProductPointSale();

        return $productPointSale;
    }

    public function createProductPointSale(Product $product, PointSale $pointSale, bool $available): ProductPointSale
    {
        $productPointSale = $this->instanciateProductPointSale();
        $productPointSale->populateProduct($product);
        $productPointSale->populatePointSale($pointSale);
        $productPointSale->available = $available;

        $this->saveCreate($productPointSale);

        return $productPointSale;
    }
}