HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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;
    }
}