uTitle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 - 2022 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\Components\Version;
24
use Syscodes\Components\Support\Str;
25
use Syscodes\Components\Support\Environment;
26
27
if ( ! function_exists('camel_case')) {
28
    /**
29
     * Convert the string with spaces or underscore in camelcase notation.
30
     *
31
     * @param  string  $string  
32
     *
33
     * @return string
34
     * 
35
     * @uses   Str::camelcase
36
     */
37
    function camel_case($string)
38
    {
39
        return Str::camelcase($string);
40
    }
41
}
42
43
if ( ! function_exists('class_basename')) {
44
    /**
45
     * Get the class "basename" of the given object / class.
46
     *
47
     * @param  string|object  $class
48
     * 
49
     * @return string
50
     */
51
    function class_basename($class)
52
    {
53
        $className = is_object($class) ? get_class($class) : $class;
54
55
        return basename(
56
            str_replace('\\', '/', $className)
57
        );
58
    }
59
}
60
61
if ( ! function_exists('class_recursive'))
62
{
63
    /**
64
     * Returns all traits used by a class, it's subclasses and trait of their traits
65
     * 
66
     * @param  string  $class
67
     * 
68
     * @return array
69
     */
70
    function class_recursive($class)
71
    {
72
        $results = [];
73
        
74
        foreach (array_merge(array($class => $class), class_parents($class)) as $class) {
0 ignored issues
show
introduced by
$class is overwriting one of the parameters of this function.
Loading history...
75
            $results += trait_recursive($class);
76
        }
77
        
78
        return array_unique($results);
79
    }
80
}
81
82
if ( ! function_exists('dd')) {
83
    /**
84
     * Generate test of variables.
85
     * 
86
     * @param  mixed
87
     * 
88
     * @return void
89
     */
90
    function dd()
91
    {
92
        array_map(function ($x) {
93
            var_dump($x);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($x) looks like debug code. Are you sure you do not want to remove it?
Loading history...
94
        },  func_get_args());
95
            
96
        die(1);
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
97
    }
98
}
99
100
if ( ! function_exists('env')) {
101
    /**
102
     * Gets the value of an environment variable.
103
     * 
104
     * @param  string  $key
105
     * @param  mixed  $default  
106
     * 
107
     * @return mixed
108
     */
109
    function env($key, $default = null)
110
    {
111
        return Environment::get($key, $default);
112
    }
113
}
114
115
if ( ! function_exists('preg_replace_sub')) {
116
    /**
117
     * Replace a given pattern with each value in the array in sequentially.
118
     * 
119
     * @param  string  $pattern
120
     * @param  array   $replacements
121
     * @param  string  $subject
122
     * 
123
     * @return string
124
     */
125
    function preg_replace_sub($pattern, &$replacements, $subject)
126
    {
127
        return preg_replace_callback($pattern, function($match) use (&$replacements) {
0 ignored issues
show
Unused Code introduced by
The parameter $match is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

127
        return preg_replace_callback($pattern, function(/** @scrutinizer ignore-unused */ $match) use (&$replacements) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
128
            return array_shift($replacements);
129
        }, $subject);
130
    }
131
}
132
133
if ( ! function_exists('str_dash')) {
134
    /**
135
     * Replace in the chain the spaces by dashes.
136
     *
137
     * @param  string  $string  
138
     *
139
     * @return string
140
     *
141
     * @uses   Str::dash
142
     */
143
    function str_dash($string)
144
    {
145
        return Str::dash($string);
146
    }
147
}
148
149
if ( ! function_exists('str_humanize')) {
150
    /**
151
     * Replace in an string the underscore or dashed by spaces.
152
     *
153
     * @param  string  $string
154
     *
155
     * @return string
156
     *
157
     * @uses   Str::humanize
158
     */
159
    function str_humanize($string)
160
    {
161
        return Str::humanize($string);
162
    }
163
}
164
165
if ( ! function_exists('str_smallcase')) {
166
    /**
167
     * Converts the CamelCase string into smallcase notation.
168
     *
169
     * @param  string  $string
170
     *
171
     * @return string
172
     *
173
     * @uses   Str::smallcase
174
     */
175
    function str_smallcase($string)
176
    {
177
        return Str::smallcase($string);
178
    }
179
}
180
181
if ( ! function_exists('str_underscore')) {
182
    /**
183
     * Replace in the string the spaces by low dashes.
184
     *
185
     * @param  string  $string
186
     *
187
     * @return string
188
     *
189
     * @uses   Str::underscore
190
     */
191
    function str_underscore($string)
192
    {
193
        return Str::underscore($string);
194
    }
195
}
196
197
if ( ! function_exists('studly_caps')) {
198
    /**
199
     * Convert the string with spaces or underscore in StudlyCaps. 
200
     *
201
     * @param  string  $string
202
     *
203
     * @return string
204
     *
205
     * @uses   Str::studlycaps
206
     */
207
    function studly_caps($string)
208
    {
209
        return Str::studlycaps($string);
210
    }
211
}
212
213
if ( ! function_exists('title')) {
214
    /**
215
     * Generates the letter first of a word in upper.
216
     * 
217
     * @param  string  $string
218
     * 
219
     * @return string
220
     * 
221
     * @uses   Str::title
222
     */
223
    function title($string)
224
    {
225
        return Str::title($string);
226
    }
227
}
228
229
if ( ! function_exists('trait_recursive'))
230
{
231
    /**
232
     * Returns all traits used by a trait and its traits.
233
     * 
234
     * @param  string  $trait
235
     * 
236
     * @return array
237
     */
238
    function trait_recursive($trait)
239
    {
240
        $traits = class_uses($trait);
241
        
242
        foreach ($traits as $trait) {
0 ignored issues
show
introduced by
$trait is overwriting one of the parameters of this function.
Loading history...
243
            $traits += trait_recursive($trait);
244
        }
245
        
246
        return $traits;
247
    }
248
}
249
250
if ( ! function_exists('uTitle')) {
251
    /**
252
     * Convert the given string to title case in UTF-8 format.
253
     * 
254
     * @param  string  $string
255
     * 
256
     * @return string
257
     * 
258
     * @uses   Str::uTitle
259
     */
260
    function uTitle($string)
261
    {
262
        return Str::uTitle($string);
263
    }
264
}
265
266
if ( ! function_exists('version')) {
267
    /**
268
     * Return number version of the Lenevor.
269
     * 
270
     * @return string
271
     */
272
    function version()
273
    {
274
        return Version::RELEASE.'-'.Version::STATUS;
275
    }
276
}
277
278
if ( ! function_exists('winOS')) {
279
    /**
280
     * Determine whether the current envrionment is Windows based.
281
     *
282
     * @return bool
283
     */
284
    function winOS()
285
    {
286
        return strtolower(substr(PHP_OS, 0, 3)) === 'win';
287
    }
288
}
289
290
if ( ! function_exists('with')) {
291
    /**
292
     * Return the given value, optionally passed through the given callback.
293
     * 
294
     * @param  mixed  $value
295
     * @param  \callable|null  $callback
0 ignored issues
show
Bug introduced by
The type callable was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
296
     * 
297
     * @return mixed
298
     */
299
    function with($value, callable $callback = null)
300
    {
301
        return is_null($callback) ? $value : $callback($value);
302
    }
303
}