File: D:/HostingSpaces/SBogers10/shop.komma.nl/app/Discounts/DiscountableTrait.php
<?php declare(strict_types=1);
namespace App\Discounts;
use App\Vat\Models\FinancialProperties;
use Illuminate\Support\Collection;
/**
* Trait DiscountableTrait
*
* @package App\Discounts
* @see DiscountableInterface
*/
trait DiscountableTrait
{
private Collection $discounts;
private Collection $discountPriceMutations;
/**
* @param Collection $discounts
*
* @return DiscountableInterface
*/
public function setDiscounts(Collection $discounts): DiscountableInterface {
$this->discounts = $discounts;
return $this;
}
/**
* @return $this|DiscountableInterface
*/
public function clearDiscounts(): DiscountableInterface {
$this->discounts = new Collection();
$this->discountPriceMutations = new Collection();
return $this;
}
/**
* The amount in cents on how to modify the price in case a discount was applied.
* -1000 means a discount of 10 euro's. There can be more then one mutation, so they are stored in
* a collection. Keyed by a human readable description.
*
* @param string $description
* @param FinancialProperties $priceMutation
*
* @return DiscountableInterface
*/
public function addDiscountPriceMutation(string $description, FinancialProperties $priceMutation): DiscountableInterface
{
$this->discountPriceMutations->put($description, $priceMutation);
return $this;
}
/**
* The amount in cents on how to modify the price in case a discount was applied.
* -1000 means a discount of 10 euro's. There can be more then one mutation, so they are stored in
* a collection. Keyed by a human readable description.
*
* @return Collection|FinancialProperties
*/
public function getDiscountPriceMutations(): Collection
{
return $this->discountPriceMutations;
}
}