Completed
Pull Request — 5.1 (#144)
by
unknown
04:21
created

helpers.php ➔ is_asociative_array()   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 Analogue\ORM\System\Manager;
4
use Analogue\ORM\System\Mapper;
5
6
if (! function_exists('analogue')) {
7
8
    /**
9
     * Return analogue's manager instance
10
     * 
11
     * @return \Analogue\ORM\System\Manager
12
     */
13
    function analogue()
14
    {
15
        return Manager::getInstance();
16
    }
17
}
18
19
20
if (! function_exists('mapper')) {
21
22
    /**
23
     * Create a mapper for a given entity (static alias)
24
     * 
25
     * @param \Analogue\ORM\Mappable|string $entity
26
     * @param mixed $entityMap 
27
     * @return Mapper
28
     */
29
    function mapper($entity, $entityMap = null)
30
    {
31
        return Manager::getMapper($entity, $entityMap);
32
    }
33
}
34
35
36
if (! function_exists('is_asociative_array')) {
37
38
    /**
39
     * Checks if an array is an asociative array
40
     * 
41
     * @param array $array
42
     * @return bool
43
     */
44
    function is_asociative_array(array $array)
45
    {
46
        return count(array_filter(array_keys($array), 'is_string')) > 0;
47
    }
48
}
49