File: D:/HostingSpaces/SBogers10/komma.pro/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);
}