SnakeCase::join()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 7
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 7
loc 7
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of Camel.
5
 *
6
 * (c) Matthieu Moquet <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Camel\Format;
13
14
/**
15
 * Format to handle sneak_case.
16
 *
17
 * @author Matthieu Moquet <[email protected]>
18
 */
19 View Code Duplication
class SnakeCase implements FormatInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function split($word)
25
    {
26
        return explode('_', $word);
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function join(array $words)
33
    {
34
        // Ensure words are lowercase
35
        $words = array_map('strtolower', $words);
36
37
        return implode('_', $words);
38
    }
39
}
40