# fluent-cart/1.6.4/app/Helpers/HelperTrait.php

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version 1.6.4. 64 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/1.6.4/code/app/Helpers/HelperTrait.php
- Raw: https://pluginprobe.com/plugins/fluent-cart/1.6.4/raw/app/Helpers/HelperTrait.php
- Modified: 2025-10-14T16:36:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-cart/1.6.4/code/app/Helpers/HelperTrait.php#L10-L20`.

```php
<?php

namespace FluentCart\App\Helpers;


/**
 * todo - need to consult with heera bhai regarding the approach of these common functions
 *
 */
trait HelperTrait
{
    private static array $orderByEnum = ['ASC', 'DESC'];


    /**
     *
     * @param $val
     * @param $stack
     * @param $def
     * @return mixed|string
     */
    private static function getValWithinEnum($val, $stack, $def = '')
    {
        return in_array($val, $stack) ? $val : $def;
    }


    /**
     *
     *
     * @param array $val
     * @param array $stack
     * @param array|string $def
     * @return array|string[]
     */
    private static function getArrValWithinEnum(array $val, array $stack, $def = ''): array
    {
        $ret = [];

        if (empty($val)) {

            return [];
        }

        foreach ($val as $item) {
            if (in_array($item, $stack)) {
                $ret[] = $item;
            }
        }

        if (empty($ret)) {

            if (is_array($def)) {

                return $def;
            }

            return [$def];
        }

        return $ret;
    }
}

```
