-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelper.php
More file actions
74 lines (66 loc) · 1.97 KB
/
helper.php
File metadata and controls
74 lines (66 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
declare(strict_types=1);
use Midnite81\Core\Converters\TimeConverter;
if (!function_exists('uuid')) {
/**
* [Aliased] Generates as UUID 4 string
*
* Example Usage: uuid()
* Example Return: 90517cea-8a9e-46c1-8c44-1a3c03611786
*/
function uuid(): string
{
return \Midnite81\Core\Functions\uuid();
}
}
if (!function_exists('first_value')) {
/**
* [Aliased] Returns the first argument which is not null, or an empty string
*
* Example: first_value(null, '', 'Dave');
* Result: Dave
*/
function first_value(): mixed
{
$args = func_get_args();
return \Midnite81\Core\Functions\first_value(...$args);
}
}
if (!function_exists('first_value_from_array')) {
/**
* [Aliased] Retrieve the first non-empty value from an array, or a default value if none found.
*
* Example: \Midnite81\Core\Functions\first_value_from_array(['', null, 'Dave']);
* Result: Dave
*
* @param array $array The input array to search for values.
* @param mixed $default The default value to return if no non-empty value is found (default: null).
* @return mixed The first non-empty value from the array, or the default value if none found.
*/
function first_value_from_array(array $array, mixed $default = null): mixed
{
return \Midnite81\Core\Functions\first_value_from_array($array);
}
}
if (!function_exists('enum')) {
/**
* [Aliased] Returns the value of a backed enum case
* If the $value is not a Backed Enum Case, a runtime error will be thrown
*
* Example usage: enum(\Midnite81\Core\Enums\ExpectedType::String)
* Result: string
*/
function enum(mixed $value): mixed
{
return \Midnite81\Core\Functions\enum($value);
}
}
if (!function_exists('tempus')) {
/**
* Returns a new instance of the TimeConverter
*/
function tempus(): TimeConverter
{
return new TimeConverter;
}
}