PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.15.5
Independent Analytics – WordPress Analytics Plugin v2.15.5
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / illuminate / collections / helpers.php
independent-analytics / vendor / illuminate / collections Last commit date
Traits 1 month ago Arr.php 1 month ago Collection.php 1 month ago Enumerable.php 1 month ago HigherOrderCollectionProxy.php 2 years ago ItemNotFoundException.php 2 years ago LazyCollection.php 1 month ago MultipleItemsFoundException.php 1 month ago helpers.php 1 month ago
helpers.php
178 lines
1 <?php
2
3 namespace IAWPSCOPED;
4
5 use IAWPSCOPED\Illuminate\Support\Arr;
6 use IAWPSCOPED\Illuminate\Support\Collection;
7 if (!\function_exists('IAWPSCOPED\\collect')) {
8 /**
9 * Create a collection from the given value.
10 *
11 * @template TKey of array-key
12 * @template TValue
13 *
14 * @param \Illuminate\Contracts\Support\Arrayable<TKey, TValue>|iterable<TKey, TValue>|null $value
15 * @return \Illuminate\Support\Collection<TKey, TValue>
16 * @internal
17 */
18 function collect($value = [])
19 {
20 return new Collection($value);
21 }
22 }
23 if (!\function_exists('IAWPSCOPED\\data_fill')) {
24 /**
25 * Fill in data where it's missing.
26 *
27 * @param mixed $target
28 * @param string|array $key
29 * @param mixed $value
30 * @return mixed
31 * @internal
32 */
33 function data_fill(&$target, $key, $value)
34 {
35 return data_set($target, $key, $value, \false);
36 }
37 }
38 if (!\function_exists('IAWPSCOPED\\data_get')) {
39 /**
40 * Get an item from an array or object using "dot" notation.
41 *
42 * @param mixed $target
43 * @param string|array|int|null $key
44 * @param mixed $default
45 * @return mixed
46 * @internal
47 */
48 function data_get($target, $key, $default = null)
49 {
50 if (\is_null($key)) {
51 return $target;
52 }
53 $key = \is_array($key) ? $key : \explode('.', $key);
54 foreach ($key as $i => $segment) {
55 unset($key[$i]);
56 if (\is_null($segment)) {
57 return $target;
58 }
59 if ($segment === '*') {
60 if ($target instanceof Collection) {
61 $target = $target->all();
62 } elseif (!\is_iterable($target)) {
63 return \IAWPSCOPED\value($default);
64 }
65 $result = [];
66 foreach ($target as $item) {
67 $result[] = \IAWPSCOPED\data_get($item, $key);
68 }
69 return \in_array('*', $key) ? Arr::collapse($result) : $result;
70 }
71 if (Arr::accessible($target) && Arr::exists($target, $segment)) {
72 $target = $target[$segment];
73 } elseif (\is_object($target) && isset($target->{$segment})) {
74 $target = $target->{$segment};
75 } else {
76 return \IAWPSCOPED\value($default);
77 }
78 }
79 return $target;
80 }
81 }
82 if (!\function_exists('IAWPSCOPED\\data_set')) {
83 /**
84 * Set an item on an array or object using dot notation.
85 *
86 * @param mixed $target
87 * @param string|array $key
88 * @param mixed $value
89 * @param bool $overwrite
90 * @return mixed
91 * @internal
92 */
93 function data_set(&$target, $key, $value, $overwrite = \true)
94 {
95 $segments = \is_array($key) ? $key : \explode('.', $key);
96 if (($segment = \array_shift($segments)) === '*') {
97 if (!Arr::accessible($target)) {
98 $target = [];
99 }
100 if ($segments) {
101 foreach ($target as &$inner) {
102 data_set($inner, $segments, $value, $overwrite);
103 }
104 } elseif ($overwrite) {
105 foreach ($target as &$inner) {
106 $inner = $value;
107 }
108 }
109 } elseif (Arr::accessible($target)) {
110 if ($segments) {
111 if (!Arr::exists($target, $segment)) {
112 $target[$segment] = [];
113 }
114 data_set($target[$segment], $segments, $value, $overwrite);
115 } elseif ($overwrite || !Arr::exists($target, $segment)) {
116 $target[$segment] = $value;
117 }
118 } elseif (\is_object($target)) {
119 if ($segments) {
120 if (!isset($target->{$segment})) {
121 $target->{$segment} = [];
122 }
123 data_set($target->{$segment}, $segments, $value, $overwrite);
124 } elseif ($overwrite || !isset($target->{$segment})) {
125 $target->{$segment} = $value;
126 }
127 } else {
128 $target = [];
129 if ($segments) {
130 data_set($target[$segment], $segments, $value, $overwrite);
131 } elseif ($overwrite) {
132 $target[$segment] = $value;
133 }
134 }
135 return $target;
136 }
137 }
138 if (!\function_exists('IAWPSCOPED\\head')) {
139 /**
140 * Get the first element of an array. Useful for method chaining.
141 *
142 * @param array $array
143 * @return mixed
144 * @internal
145 */
146 function head($array)
147 {
148 return \reset($array);
149 }
150 }
151 if (!\function_exists('IAWPSCOPED\\last')) {
152 /**
153 * Get the last element from an array.
154 *
155 * @param array $array
156 * @return mixed
157 * @internal
158 */
159 function last($array)
160 {
161 return \end($array);
162 }
163 }
164 if (!\function_exists('IAWPSCOPED\\value')) {
165 /**
166 * Return the default value of the given value.
167 *
168 * @param mixed $value
169 * @param mixed ...$args
170 * @return mixed
171 * @internal
172 */
173 function value($value, ...$args)
174 {
175 return $value instanceof \Closure ? $value(...$args) : $value;
176 }
177 }
178