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/farmfun.komma.pro/app/Komma/Shop/Discounts/DiscountTypes.php
<?php

namespace App\Komma\Shop\Discounts;

/**
 * Class DiscountTypes
 *
 * Represents discounts. These values determine which condition an action wil be used in a discountServiceInterface instance
 */
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
     */
    public 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
     */
    public 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();
    }
}