Completed
Push — master ( 34dca7...be5342 )
by Antonio Carlos
02:29
created

helpers.php ➔ starts_with()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
use IlluminateAgnostic\Str\Support\Str;
4
use PragmaRX\Coollection\Package\Coollection;
5
6
if (!class_exists(Illuminate\Support\Collection::class)) {
7
    if (!function_exists('coollect')) {
8
        /**
9
         * Create a collection from the given value.
10
         *
11
         * @param  mixed  $value
12
         * @return \PragmaRX\Coollection\Package\Coollection
13
         */
14
        function coollect($value = null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
15
        {
16 120
            if ($value instanceof Coollection) {
17 1
                return $value;
18
            }
19
20 120
            return new Coollection($value);
21
        }
22
    }
23
24
    /**
25
     * @codeCoverageIgnore
26
     */
27
    if (!function_exists('dump')) {
28
        function dump(...$args)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
29
        {
30
            foreach ($args as $value) {
31
                var_dump($value);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($value); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
32
            }
33
        }
34
    }
35
36
    /**
37
     * @codeCoverageIgnore
38
     */
39
    if (!function_exists('dd')) {
40
        function dd(...$args)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
41
        {
42
            dump(...$args);
43
44
            die();
45
        }
46
    }
47
48
    if (!function_exists('array_sort_by_keys_recursive')) {
49
        /**
50
         * Determine if a given string starts with a given substring.
51
         *
52
         * @param array $array
53
         */
54
        function array_sort_by_keys_recursive(array &$array)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
55
        {
56 2
            ksort($array, SORT_NATURAL);
57
58 2
            foreach ($array as $key => $value) {
59 2
                if (is_array($value)) {
60 2
                    array_sort_by_keys_recursive($array[$key]);
61
                }
62
            }
63 2
        }
64
    }
65
66
    if (! function_exists('with')) {
67
        /**
68
         * Return the given object. Useful for chaining.
69
         *
70
         * @param  mixed  $object
71
         * @return mixed
72
         */
73
        function with($object)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
74
        {
75 1
            return $object;
76
        }
77
    }
78
}
79