Completed
Push — master ( 2d2cd2...bd6534 )
by Elf
04:49
created

mb_trim()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
nc 1
nop 1
dl 0
loc 3
c 1
b 0
f 0
cc 1
ccs 0
cts 1
cp 0
crap 2
rs 10
1
<?php
2
3
use Illuminate\Contracts\Support\Jsonable;
4
5
if (! function_exists('in_arrayi')) {
6
    /**
7
     * Case insensitive `in_array`.
8
     *
9
     * @see https://secure.php.net/manual/en/function.in-array.php#89256
10
     *
11
     * @param  string  $needle
12
     * @param  array  $haystack
13
     * @return bool
14
     */
15
    function in_arrayi($needle, $haystack)
16
    {
17
        return in_array(strtolower($needle), array_map('strtolower', $haystack));
18
    }
19
}
20
21
if (! function_exists('mb_trim')) {
22
    /**
23
     * Strip whitespace (or other characters) from the beginning and end of a string.
24
     *
25
     * @see https://github.com/vanderlee/PHP-multibyte-functions/blob/master/functions/mb_trim.php
26
     *
27
     * @param  string  $string
28
     * @return string
29
     */
30
    function mb_trim($string)
31
    {
32
        return mb_ereg_replace('^\s*([\s\S]*?)\s*$', '\1', $string);
33
    }
34
}
35
36
if (! function_exists('string_value')) {
37
    /**
38
     * Convert any type to a string.
39
     *
40
     * @param  mixed  $value
41
     * @param  int  $jsonOptions
42
     * @return string
43
     */
44
    function string_value($value, $jsonOptions = 0)
45
    {
46
        $jsonOptions |= JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
47
48
        if (is_string($value)) {
49
            return $value;
50
        } elseif ($value instanceof Jsonable) {
51
            return $value->toJson($jsonOptions);
52
        } elseif (method_exists($value, 'toArray')) {
53
            $value = $value->toArray();
54
        } elseif ($value instanceof Traversable) {
55
            $value = iterator_to_array($value);
56
        } elseif (method_exists($value, '__toString')) {
57
            return (string) $value;
58
        }
59
60
        return json_encode($value, $jsonOptions);
61
    }
62
}
63
64
if (! function_exists('active')) {
65
    /**
66
     * Return "active" if the current request URI matches the given patterns.
67
     *
68
     * @param  dynamic  $patterns
0 ignored issues
show
Bug introduced by
The type dynamic 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...
69
     * @return string
70
     */
71
    function active(...$patterns)
72
    {
73
        return request()->is(...$patterns) ? 'active' : '';
74
    }
75
}
76