Test Setup Failed
Push — master ( 7f80a6...f6af0d )
by Carlos
02:39
created

Helpers.php ➔ snake_case()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the overtrue/cuttle.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Overtrue\Cuttle;
13
14
/**
15
 * To camel case.
16
 *
17
 * @param string $str
18
 *
19
 * @return string
20
 */
21
function camel_case(string $str)
1 ignored issue
show
Coding Style introduced by
function camel_case() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
22
{
23
    return lcfirst(studly_case($str));
24
}
25
26
/**
27
 * To snake case.
28
 *
29
 * @param string $str
30
 *
31
 * @return mixed|string
32
 */
33
function snake_case(string $str)
1 ignored issue
show
Coding Style introduced by
function snake_case() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
34
{
35
    if (ctype_lower($str)) {
36
        return $str;
37
    }
38
39
    return mb_strtolower(preg_replace('/(.)(?=[A-Z])/u', '$1_', preg_replace('/\s+/u', '', $str)), 'utf-8');
40
}
41
42
/**
43
 * To studly case.
44
 *
45
 * @param string $str
46
 *
47
 * @return string
48
 */
49
function studly_case(string $str)
1 ignored issue
show
Coding Style introduced by
function studly_case() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
50
{
51
    return ucwords(str_replace(['-', '_'], ' ', trim($str)));
52
}
53