1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Support\Str; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* generate sequence |
7
|
|
|
* @return sequence based on length supplied |
8
|
|
|
*/ |
9
|
|
|
if (! function_exists('generate_sequence')) { |
10
|
|
|
function generate_sequence($input = 1) |
11
|
|
|
{ |
12
|
|
|
return str_pad($input, config('helper.sequence_length'), '0', STR_PAD_LEFT); |
13
|
|
|
} |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
/* |
17
|
|
|
* Get Abbreviation fo the given text |
18
|
|
|
*/ |
19
|
|
|
if (! function_exists('abbrv')) { |
20
|
|
|
function abbrv($value, $unique_characters = true) |
21
|
|
|
{ |
22
|
|
|
if (true === config('helper.abbrv.remove_non_alphanumeric')) { |
23
|
|
|
$value = preg_replace('/[^A-Za-z0-9 ]/', '', $value); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
$value = str_replace( |
27
|
|
|
config('helper.abbrv.remove_vowels'), |
28
|
|
|
'', |
29
|
|
|
$value); |
30
|
|
|
|
31
|
|
|
if (true === config('helper.abbrv.to_uppercase')) { |
32
|
|
|
$value = strtoupper($value); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
if (true == config('helper.abbrv.unique_characters') || true == $unique_characters) { |
36
|
|
|
$split = str_split($value); |
37
|
|
|
$unique_characters = []; |
38
|
|
|
foreach ($split as $character) { |
39
|
|
|
if (! in_array($character, $unique_characters)) { |
40
|
|
|
$unique_characters[] = $character; |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return implode('', $unique_characters); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
return $value; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/* |
52
|
|
|
* Get Fully Qualified Class Name (FQCN) for an Object |
53
|
|
|
*/ |
54
|
|
|
if (! function_exists('fqcn')) { |
55
|
|
|
function fqcn($object) |
56
|
|
|
{ |
57
|
|
|
return get_class($object); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/* |
62
|
|
|
* Get Slug Name for Fully Qualified Class Name (FQCN) |
63
|
|
|
*/ |
64
|
|
|
if (! function_exists('str_slug_fqcn')) { |
65
|
|
|
function str_slug_fqcn($object) |
66
|
|
|
{ |
67
|
|
|
return Str::kebab(fqcn($object)); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/* |
72
|
|
|
* Send Notification To User |
73
|
|
|
*/ |
74
|
|
|
if (! function_exists('notify')) { |
75
|
|
|
function notify($identifier, $column = 'id') |
76
|
|
|
{ |
77
|
|
|
return \CleaniqueCoders\LaravelHelper\Services\NotificationService::make($identifier, $column); |
|
|
|
|
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.