This repository was archived by the owner on Jun 3, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelper.php
More file actions
102 lines (93 loc) · 1.86 KB
/
Copy pathHelper.php
File metadata and controls
102 lines (93 loc) · 1.86 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
declare(strict_types = 1);
/**
* Helper
* @author George Martinec <github.com/george-martinec>
*
* @noinspection PhpUnused
*/
class Helper {
/**
* Convert array to object
*
* @param array $array
*
* @return object
* @noinspection PhpUnused
*/
public static function toObject(
array $array
) {
return (object) $array;
}
/**
* Calculate the sum of the ArrayColumn
*
* @param array $array
* @param string $column_key
*
* @return int|float
* @noinspection PhpUnused
*/
public static function sumArrayColumn(
array $array,
string $column_key
) {
return array_sum(
array_column($array, $column_key)
);
}
/**
* Get current date in GoodDay format
*
* @return string
* @noinspection PhpUnused
*/
public static function currentDate(): string
{
return date("Y-m-d", strtotime("now"));
}
/**
* Get date in GoodDay format
*
* @param string $datetime
*
* @url https://www.php.net/manual/en/function.strtotime.php
*
* @return string
* @noinspection PhpUnused
*/
public static function getDate(string $datetime): string
{
return date("Y-m-d", strtotime($datetime));
}
/**
* Dump
*
* @return void
* @noinspection PhpUnused
*/
public static function d()
{
print("<pre>");
foreach (func_get_args() as $arg) {
print_r($arg);
}
print("</pre>");
}
/**
* Dump and Die
*
* @return void
* @noinspection PhpUnused
*/
public static function dd()
{
print("<pre>");
foreach (func_get_args() as $arg) {
print_r($arg);
}
print("</pre>");
exit();
}
}