Failed Conditions
Pull Request — master (#2)
by Arnold
06:44
created

case_functions.php ➔ uncase()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 5
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
1
<?php
2
3
namespace Jasny;
4
5
/**
6
 * Turn a sentence, camelCase, snake_case or kabab-case into camelCase
7
 *
8
 * @param string $string
9
 * @return string
10
 */
11
function camelcase($string)
0 ignored issues
show
Best Practice introduced by
The function Jasny\camelcase() has been defined more than once; this definition is ignored, only the first definition in global.php (L99-102) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
12
{
13 6
    $sentence = preg_replace('/[\W_]+/', ' ', $string);
14 6
    return lcfirst(str_replace(' ', '', ucwords($sentence)));
15
}
16
17
/**
18
 * Turn a sentence, camelCase, snake_case or kabab-case into StudlyCase
19
 *
20
 * @param string $string
21
 * @return string
22
 */
23
function studlycase($string)
0 ignored issues
show
Best Practice introduced by
The function Jasny\studlycase() has been defined more than once; this definition is ignored, only the first definition in global.php (L110-113) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
24
{
25 6
    $sentence = preg_replace('/[\W_]+/', ' ', $string);
26 6
    return str_replace(' ', '', ucwords($sentence));
27
}
28
29
/**
30
 * Turn a sentence, camelCase, StudlyCase or kabab-case into snake_case
31
 *
32
 * @param string $string
33
 * @return string
34
 */
35
function snakecase($string)
0 ignored issues
show
Best Practice introduced by
The function Jasny\snakecase() has been defined more than once; this definition is ignored, only the first definition in global.php (L121-124) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
36
{
37 6
    $sentence = strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1 $2', $string));
38 6
    return preg_replace('/[\W\_]+/', '_', $sentence);
39
}
40
41
/**
42
 * Turn a sentence, camelCase, StudlyCase or snake_case into kabab-case
43
 *
44
 * @param string $string
45
 * @return string
46
 */
47
function kababcase($string)
0 ignored issues
show
Best Practice introduced by
The function Jasny\kababcase() has been defined more than once; this definition is ignored, only the first definition in global.php (L132-135) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
48
{
49 6
    $sentence = strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1 $2', $string));
50 6
    return preg_replace('/[\W\_]+/', '-', $sentence);
51
}
52
53
/**
54
 * Turn StudlyCase, camelCase, snake_case or kabab-case into a sentence.
55
 *
56
 * @param string $string
57
 * @return string
58
 */
59
function uncase($string)
0 ignored issues
show
Best Practice introduced by
The function Jasny\uncase() has been defined more than once; this definition is ignored, only the first definition in global.php (L143-146) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
60
{
61 6
    $snake = strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1 $2', $string));
62 6
    $sentence = preg_replace('/[-_\s]+/', ' ', $snake);
63
    
64 6
    return $sentence;
65
}
66