|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Lenevor Framework |
|
5
|
|
|
* |
|
6
|
|
|
* LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the new BSD license that is bundled |
|
9
|
|
|
* with this package in the file license.md. |
|
10
|
|
|
* It is also available through the world-wide-web at this URL: |
|
11
|
|
|
* https://lenevor.com/license |
|
12
|
|
|
* If you did not receive a copy of the license and are unable to |
|
13
|
|
|
* obtain it through the world-wide-web, please send an email |
|
14
|
|
|
* to [email protected] so we can send you a copy immediately. |
|
15
|
|
|
* |
|
16
|
|
|
* @package Lenevor |
|
17
|
|
|
* @subpackage Base |
|
18
|
|
|
* @link https://lenevor.com |
|
19
|
|
|
* @copyright Copyright (c) 2019 - 2021 Alexander Campo <[email protected]> |
|
20
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
use Syscodes\Version; |
|
24
|
|
|
use Syscodes\Support\Str; |
|
25
|
|
|
use Syscodes\Support\Environment; |
|
26
|
|
|
|
|
27
|
|
|
if ( ! function_exists('camel_case')) |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* Convert the string with spaces or underscore in camelcase notation. |
|
31
|
|
|
* |
|
32
|
|
|
* @param string $string |
|
33
|
|
|
* |
|
34
|
|
|
* @return string |
|
35
|
|
|
* |
|
36
|
|
|
* @uses Str::camelcase |
|
37
|
|
|
*/ |
|
38
|
|
|
function camel_case($string) |
|
39
|
|
|
{ |
|
40
|
|
|
return Str::camelcase($string); |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
if ( ! function_exists('classBasename')) |
|
45
|
|
|
{ |
|
46
|
|
|
/** |
|
47
|
|
|
* Get the class "basename" of the given object / class. |
|
48
|
|
|
* |
|
49
|
|
|
* @param string|object $class |
|
50
|
|
|
* |
|
51
|
|
|
* @return string |
|
52
|
|
|
*/ |
|
53
|
|
|
function classBasename($class) |
|
54
|
|
|
{ |
|
55
|
|
|
$class = is_object($class) ? get_class($class) : $class; |
|
56
|
|
|
|
|
57
|
|
|
return basename(str_replace('\\', '/', $class)); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
if ( ! function_exists('dd')) |
|
62
|
|
|
{ |
|
63
|
|
|
/** |
|
64
|
|
|
* Generate test of variables. |
|
65
|
|
|
* |
|
66
|
|
|
* @param mixed |
|
67
|
|
|
* |
|
68
|
|
|
* @return void |
|
69
|
|
|
*/ |
|
70
|
|
|
function dd() |
|
71
|
|
|
{ |
|
72
|
|
|
array_map(function ($x) { |
|
73
|
|
|
var_dump($x); |
|
|
|
|
|
|
74
|
|
|
}, func_get_args()); |
|
75
|
|
|
|
|
76
|
|
|
die(1); |
|
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
if ( ! function_exists('env')) |
|
81
|
|
|
{ |
|
82
|
|
|
/** |
|
83
|
|
|
* Gets the value of an environment variable. |
|
84
|
|
|
* |
|
85
|
|
|
* @param string $key |
|
86
|
|
|
* @param mixed $default |
|
87
|
|
|
* |
|
88
|
|
|
* @return mixed |
|
89
|
|
|
*/ |
|
90
|
|
|
function env($key, $default = null) |
|
91
|
|
|
{ |
|
92
|
|
|
return Environment::get($key, $default); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
if ( ! function_exists('str_dash')) |
|
97
|
|
|
{ |
|
98
|
|
|
/** |
|
99
|
|
|
* Replace in the chain the spaces by dashes. |
|
100
|
|
|
* |
|
101
|
|
|
* @param string $string |
|
102
|
|
|
* |
|
103
|
|
|
* @return string |
|
104
|
|
|
* |
|
105
|
|
|
* @uses Str::dash |
|
106
|
|
|
*/ |
|
107
|
|
|
function str_dash($string) |
|
108
|
|
|
{ |
|
109
|
|
|
return Str::dash($string); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
if ( ! function_exists('str_humanize')) |
|
114
|
|
|
{ |
|
115
|
|
|
/** |
|
116
|
|
|
* Replace in an string the underscore or dashed by spaces. |
|
117
|
|
|
* |
|
118
|
|
|
* @param string $string |
|
119
|
|
|
* |
|
120
|
|
|
* @return string |
|
121
|
|
|
* |
|
122
|
|
|
* @uses Str::humanize |
|
123
|
|
|
*/ |
|
124
|
|
|
function str_humanize($string) |
|
125
|
|
|
{ |
|
126
|
|
|
return Str::humanize($string); |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
if ( ! function_exists('str_smallcase')) |
|
131
|
|
|
{ |
|
132
|
|
|
/** |
|
133
|
|
|
* Converts the CamelCase string into smallcase notation. |
|
134
|
|
|
* |
|
135
|
|
|
* @param string $string |
|
136
|
|
|
* |
|
137
|
|
|
* @return string |
|
138
|
|
|
* |
|
139
|
|
|
* @uses Str::smallcase |
|
140
|
|
|
*/ |
|
141
|
|
|
function str_smallcase($string) |
|
142
|
|
|
{ |
|
143
|
|
|
return Str::smallcase($string); |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
if ( ! function_exists('str_underscore')) |
|
148
|
|
|
{ |
|
149
|
|
|
/** |
|
150
|
|
|
* Replace in the string the spaces by low dashes. |
|
151
|
|
|
* |
|
152
|
|
|
* @param string $string |
|
153
|
|
|
* |
|
154
|
|
|
* @return string |
|
155
|
|
|
* |
|
156
|
|
|
* @uses Str::underscore |
|
157
|
|
|
*/ |
|
158
|
|
|
function str_underscore($string) |
|
159
|
|
|
{ |
|
160
|
|
|
return Str::underscore($string); |
|
161
|
|
|
} |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
if ( ! function_exists('studly_caps')) |
|
165
|
|
|
{ |
|
166
|
|
|
/** |
|
167
|
|
|
* Convert the string with spaces or underscore in StudlyCaps. |
|
168
|
|
|
* |
|
169
|
|
|
* @param string $string |
|
170
|
|
|
* |
|
171
|
|
|
* @return string |
|
172
|
|
|
* |
|
173
|
|
|
* @uses Str::studlycaps |
|
174
|
|
|
*/ |
|
175
|
|
|
function studly_caps($string) |
|
176
|
|
|
{ |
|
177
|
|
|
return Str::studlycaps($string); |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
if ( ! function_exists('version')) |
|
182
|
|
|
{ |
|
183
|
|
|
/** |
|
184
|
|
|
* Return number version of the Lenevor. |
|
185
|
|
|
* |
|
186
|
|
|
* @return string |
|
187
|
|
|
*/ |
|
188
|
|
|
function version() |
|
189
|
|
|
{ |
|
190
|
|
|
return Version::RELEASE.'-'.Version::STATUS; |
|
191
|
|
|
} |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
if ( ! function_exists('winOS')) |
|
195
|
|
|
{ |
|
196
|
|
|
/** |
|
197
|
|
|
* Determine whether the current envrionment is Windows based. |
|
198
|
|
|
* |
|
199
|
|
|
* @return bool |
|
200
|
|
|
*/ |
|
201
|
|
|
function winOS() |
|
202
|
|
|
{ |
|
203
|
|
|
return strtolower(substr(PHP_OS, 0, 3)) === 'win'; |
|
204
|
|
|
} |
|
205
|
|
|
} |