PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / trunk
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler vtrunk
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / app / Helpers / HelperTrait.php

HelperTrait.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler trunk, at app/Helpers/HelperTrait.php

64 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Helpers;
4
5
6 /**
7 * todo - need to consult with heera bhai regarding the approach of these common functions
8 *
9 */
10 trait HelperTrait
11 {
12 private static array $orderByEnum = ['ASC', 'DESC'];
13
14
15 /**
16 *
17 * @param $val
18 * @param $stack
19 * @param $def
20 * @return mixed|string
21 */
22 private static function getValWithinEnum($val, $stack, $def = '')
23 {
24 return in_array($val, $stack) ? $val : $def;
25 }
26
27
28 /**
29 *
30 *
31 * @param array $val
32 * @param array $stack
33 * @param array|string $def
34 * @return array|string[]
35 */
36 private static function getArrValWithinEnum(array $val, array $stack, $def = ''): array
37 {
38 $ret = [];
39
40 if (empty($val)) {
41
42 return [];
43 }
44
45 foreach ($val as $item) {
46 if (in_array($item, $stack)) {
47 $ret[] = $item;
48 }
49 }
50
51 if (empty($ret)) {
52
53 if (is_array($def)) {
54
55 return $def;
56 }
57
58 return [$def];
59 }
60
61 return $ret;
62 }
63 }
64