Completed
Push — master ( 56096b...601ee3 )
by Sergey
12s
created

array_functions.php ➔ array_last()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Larapulse\Support\Handlers\Arr;
4
use Illuminate\Support\Arr as IlluminateArr;
5
6
if (!function_exists('array_flatten')) {
7
    /**
8
     * Flatten a multi-dimensional array into a single level
9
     *
10
     * @param  array  $array
11
     * @param  int  $depth
12
     * @return array
13
     */
14
    function array_flatten($array, $depth = INF) : array
15
    {
16
        return Arr::flatten($array, $depth);
17
    }
18
}
19
20
if (!function_exists('array_flatten_assoc')) {
21
    /**
22
     * Flatten a multi-dimensional array into a single level with saving keys
23
     *
24
     * @param  array  $array
25
     * @param  int   $depth
26
     * @return array
27
     */
28
    function array_flatten_assoc(array $array, $depth = INF) : array
29
    {
30
        return Arr::flattenAssoc($array, $depth);
31
    }
32
}
33
34
if (!function_exists('array_depth')) {
35
    /**
36
     * Get depth of array
37
     *
38
     * @param  array  $array
39
     * @return int
40
     */
41
    function array_depth($array) : int
42
    {
43
        return Arr::depth($array);
44
    }
45
}
46
47
if (!function_exists('is_array_of_type')) {
48
    /**
49
     * Check if array contains from specific type
50
     *
51
     * @param array  $array
52
     * @param string $type
53
     *
54
     * @return bool
55
     */
56
    function is_array_of_type(array $array, string $type) : bool
57
    {
58
        return Arr::isTypeOf($array, $type);
59
    }
60
}
61
62
if (!function_exists('is_array_of_types')) {
63
    /**
64
     * Check if array contains from specific types
65
     *
66
     * @param array  $array
67
     * @param array  $types
68
     *
69
     * @return bool
70
     */
71
    function is_array_of_types(array $array, array $types) : bool
72
    {
73
        return Arr::isTypesOf($array, $types);
74
    }
75
}
76
77
if (!function_exists('is_array_of_instance')) {
78
    /**
79
     * Check if array contains instances of specified class/interface
80
     *
81
     * @param array  $array
82
     * @param string $className
83
     *
84
     * @return bool
85
     */
86
    function is_array_of_instance(array $array, string $className) : bool
87
    {
88
        return Arr::isInstancesOf($array, $className);
89
    }
90
}
91
92
if (!function_exists('array_is_assoc')) {
93
    /**
94
     * Determines if an array is associative
95
     *
96
     * An array is "associative" if it doesn't have sequential numerical keys beginning with zero
97
     *
98
     * @param  array  $array
99
     * @return bool
100
     */
101
    function array_is_assoc(array $array) : bool
102
    {
103
        return IlluminateArr::isAssoc($array);
104
    }
105
}
106