toCamelCase()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
nc 2
nop 2
dl 0
loc 3
rs 10
c 2
b 0
f 0
1
<?php
2
3
/**
4
 * Returns the camel case version
5
 * of a given string.
6
 *
7
 * @param string      $string
8
 * @param string|null $prefix
9
 *
10
 * @return string
11
 */
12
function toCamelCase($string, $prefix = null)
13
{
14
    return is_null($prefix) ? ucfirst($string) : sprintf('%s%s', $prefix, ucfirst($string));
15
}
16
17
/**
18
 * Returns the snake case version
19
 * of a given string.
20
 *
21
 * @param string      $string
22
 * @param string|null $prefix
23
 *
24
 * @return string
25
 */
26
function toSnakeCase($string, $prefix = null)
27
{
28
    return is_null($prefix) ? strtolower($string) : sprintf('%s_%s', $prefix, strtolower($string));
29
}
30