Completed
Push — master ( 2135e4...0f407e )
by Mehmet
28:04 queued 13:46
created

functions.php ➔ getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 1
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Selami\Entity;
5
6
/**
7
 * A Note:
8
 * Since the built-in php function gettype returns "double" variabe type, here is the workaround function
9
 * See http://php . net/manual/en/function . gettype . php => Possible values for the returned string are:
10
 * "double" (for historical reasons "double" is returned in case of a float, and not simply "float")
11
 *
12
 * @param mixed     $value
13
 * @return string
14
 */
15
function getType($value)
16
{
17
    return [
18
        'boolean'   => 'boolean',
19
        'string'    => 'string',
20
        'integer'   => 'integer',
21
        'long'      => 'integer',
22
        'double'    => 'float',
23
        'float'     => 'float',
24
        'array'     => 'array',
25
        'null'      => 'null'
26
    ][strtolower(gettype($value))];
27
}
28