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/zipwire/zipwire.nl/app/KommaApp/Shop/Discounts/Actions/AbstractDiscountAction.php
<?php


namespace App\KommaApp\Shop\Discounts\Actions;


abstract class AbstractDiscountAction
{
    /**
     * @var string $value
     */
    protected $value;

    public function __construct($actionSettings) {
        $this->dissectDiscountValue($actionSettings);
        $this->value = $actionSettings;
    }

    /**
     * Dissect a value that comes from a discount into something that the DiscountAction understands
     *
     * @param string $discountValue
     * @return bool
     */
    abstract protected function dissectDiscountValue(string $discountValue):bool;

    /**
     * Create a new instance from the settings from a discount model
     *
     * @param string $discountActionSettings
     * @return AbstractDiscountAction
     */
    abstract public static function newInstanceFromDiscountSettings(string $discountActionSettings):AbstractDiscountAction;

    /**
     * @return string
     */
    public function getValue(): string
    {
        return $this->value;
    }

    /**
     * Receive data from outside, do the action on it, return the modified data.
     * For example: Get a price from a shopping cart, modify the price according to what this action represents and return the price to the shopping cart.
     *
     * @param array $parameters. May be specified as an array or argument1,argument2,argument3
     * @return mixed
     */
    abstract public function do(...$parameters);
}