Passed
Push — master ( fa69c0...4dbea6 )
by
unknown
02:11
created

mb_json_encode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
if (!function_exists('random_password')) {
4
    /**
5
     * Generate random password.
6
     *
7
     * @param int    $length
8
     * @param string $availableSets
9
     *
10
     * @return string
11
     */
12
    function random_password(int $length = 9, string $availableSets = 'luds')
13
    {
14
        return app('helper')->randomPassword($length, $availableSets);
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

14
        return /** @scrutinizer ignore-call */ app('helper')->randomPassword($length, $availableSets);
Loading history...
15
    }
16
}
17
18
if (!function_exists('persian_slug')) {
19
    /**
20
     * Generate persian slug.
21
     *
22
     * @param string $string
23
     * @param string $separator
24
     *
25
     * @return false|mixed|string|string[]|null
26
     */
27
    function persian_slug(string $string, string $separator = '-')
28
    {
29
        return app('helper')->persianSlug($string, $separator);
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

29
        return /** @scrutinizer ignore-call */ app('helper')->persianSlug($string, $separator);
Loading history...
30
    }
31
}
32
33
if (!function_exists('fa_to_en_nums')) {
34
    /**
35
     * Convert all Persian(Farsi) numbers to English.
36
     *
37
     * @param string $number
38
     *
39
     * @return mixed
40
     */
41
    function fa_to_en_nums(string $number)
42
    {
43
        return app('helper')->faToEnNums($number);
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

43
        return /** @scrutinizer ignore-call */ app('helper')->faToEnNums($number);
Loading history...
44
    }
45
}
46
47
if (!function_exists('remove_comma')) {
48
    /**
49
     * Remove comma's from value.
50
     *
51
     * @param string $value
52
     *
53
     * @return string
54
     */
55
    function remove_comma(string $value) : string
56
    {
57
        return app('helper')->removeComma($value);
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

57
        return /** @scrutinizer ignore-call */ app('helper')->removeComma($value);
Loading history...
58
    }
59
}
60
61
if (!function_exists('to_gregorian')) {
62
    /**
63
     * Convert jalali date to gregorian date.
64
     *
65
     * @param string $jDate
66
     *
67
     * @return null|string
68
     */
69
    function to_gregorian(string $jDate)
70
    {
71
        return app('helper')->toGregorian($jDate);
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

71
        return /** @scrutinizer ignore-call */ app('helper')->toGregorian($jDate);
Loading history...
72
    }
73
}
74
75
if (! function_exists('mb_json_encode')) {
76
    /**
77
     * json_encode() for multibyte characters
78
     *
79
     * @param mixed
80
     *
81
     * @return null|string
82
     */
83
    function mb_json_encode($input) {
84
        return preg_replace_callback('/\\\\u([0-9a-zA-Z]{4})/', function ($matches) {
85
            return mb_convert_encoding(pack('H*',$matches[1]), 'UTF-8','UTF-16');
86
        },
87
            json_encode($input, JSON_UNESCAPED_UNICODE)
88
        );
89
    }
90
}
91