File: D:/HostingSpaces/SBogers10/structura.komma.pro/app/KommaApp/Shop/Discounts/DiscountTypes.php
<?php
namespace App\KommaApp\Shop\Discounts;
/**
* Class DiscountTypes
*
* Represents discounts. These values determine which condition an action wil be used in a discountServiceInterface instance
*
* @package App\KommaApp\Shop\Discounts
*/
class DiscountTypes
{
const None = 0; //No discount
const Discountable = 1; //Applicable on a a discountable type or specific discountable's
const Quantity = 2; //Quantity discounts. Example: Order 10 products and get each of them for 2 euros a piece instead of 2,10 a piece.
const Coupon = 3; //Quantity discounts. Example: Order 10 products and get each of them for 2 euros a piece instead of 2,10 a piece.
/**
* @return int[] All types as an array of integers
* @throws \ReflectionException
*/
static function getAsArray() {
return self::getAllTypes();
}
/**
* Check if the passed type is really a type that is defined as a constant in this class.
*
* @param int $type
* @param bool $strict If true it will only consider a type as valid if it is an int. If it for example is a numeric string it won't consider it valid
* @return bool Returns true if the type is a valid one, false otherwise
* @throws \ReflectionException
*/
static function isValidType(int $type, $strict = false) {
return in_array($type, self::getAllTypes(), $strict);
}
/**
* Returns an array containing integers representing the defined types.
*
* @return int[]
* @throws \ReflectionException
*/
private static function getAllTypes()
{
$thisClassAsReflectionClass = new \ReflectionClass(__CLASS__);
return $thisClassAsReflectionClass->getConstants();
}
}