| @@ 912-920 (lines=9) @@ | ||
| 909 | * @param array|string $list |
|
| 910 | * @return bool |
|
| 911 | */ |
|
| 912 | function contains() { |
|
| 913 | static $contains = false; |
|
| 914 | $contains = $contains ?: curry(function($item, $list) { |
|
| 915 | return is_string($list) |
|
| 916 | ? (strpos($list, $item) !== false) |
|
| 917 | : in_array($item, $list); |
|
| 918 | }); |
|
| 919 | return _apply($contains, func_get_args()); |
|
| 920 | } |
|
| 921 | ||
| 922 | /** |
|
| 923 | * Returns the position/key of the first item satisfying the |
|
| @@ 1287-1295 (lines=9) @@ | ||
| 1284 | * @param array $list |
|
| 1285 | * @return array |
|
| 1286 | */ |
|
| 1287 | function sort() { |
|
| 1288 | static $sort = false; |
|
| 1289 | $sort = $sort ?: curry(function($compare, $list) { |
|
| 1290 | $result = clone_($list); |
|
| 1291 | usort($result, comparator($compare)); |
|
| 1292 | return $result; |
|
| 1293 | }); |
|
| 1294 | return _apply($sort, func_get_args()); |
|
| 1295 | } |
|
| 1296 | ||
| @@ 105-113 (lines=9) @@ | ||
| 102 | * @param object|array $object |
|
| 103 | * @return array |
|
| 104 | */ |
|
| 105 | function keys() { |
|
| 106 | static $keys = false; |
|
| 107 | $keys = $keys ?: curry(function($object) { |
|
| 108 | return is_object($object) |
|
| 109 | ? array_keys(get_object_vars($object)) |
|
| 110 | : array_keys($object); |
|
| 111 | }); |
|
| 112 | return _apply($keys, func_get_args()); |
|
| 113 | } |
|
| 114 | ||
| 115 | /** |
|
| 116 | * Returns a list of array's values or object's public attributes values. |
|
| @@ 130-138 (lines=9) @@ | ||
| 127 | * @param object|array $object |
|
| 128 | * @return array |
|
| 129 | */ |
|
| 130 | function values() { |
|
| 131 | static $values = false; |
|
| 132 | $values = $values ?: curry(function($object) { |
|
| 133 | return is_object($object) |
|
| 134 | ? array_values(get_object_vars($object)) |
|
| 135 | : array_values($object); |
|
| 136 | }); |
|
| 137 | return _apply($values, func_get_args()); |
|
| 138 | } |
|
| 139 | ||
| 140 | /** |
|
| 141 | * Checks if the given array or object has a specific key or public attribute. |
|
| @@ 197-206 (lines=10) @@ | ||
| 194 | * @param string $string |
|
| 195 | * @return bool |
|
| 196 | */ |
|
| 197 | function startsWith() { |
|
| 198 | static $startsWith = false; |
|
| 199 | $startsWith = $startsWith ?: curry(function($token, $string) { |
|
| 200 | return ( |
|
| 201 | strlen($token) <= strlen($string) && |
|
| 202 | substr($string, 0, strlen($token)) === $token |
|
| 203 | ); |
|
| 204 | }); |
|
| 205 | return _apply($startsWith, func_get_args()); |
|
| 206 | } |
|
| 207 | ||
| 208 | /** |
|
| 209 | * Checks if `$string` ends with `$token`. |
|
| @@ 223-232 (lines=10) @@ | ||
| 220 | * @param string $string |
|
| 221 | * @return bool |
|
| 222 | */ |
|
| 223 | function endsWith() { |
|
| 224 | static $endsWith = false; |
|
| 225 | $endsWith = $endsWith ?: curry(function($token, $string) { |
|
| 226 | return ( |
|
| 227 | strlen($token) <= strlen($string) && |
|
| 228 | substr($string, - strlen($token)) === $token |
|
| 229 | ); |
|
| 230 | }); |
|
| 231 | return _apply($endsWith, func_get_args()); |
|
| 232 | } |
|
| 233 | ||
| 234 | /** |
|
| 235 | * Checks if a string matches a regular expression. |
|