Completed
Push — master ( c5a357...79cf75 )
by Mehmet
07:41
created

functions.php ➔ upperCamelCase()   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
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 getDataType($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
29
/**
30
 * @param string $str
31
 * @return string
32
 */
33
function upperCamelCase(string $str)
34
{
35
    return str_replace(' ', '', ucwords(str_replace('_', ' ', $str)));
36
}
37