InflectionClassifyTrait::doClassify()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Nip\Inflector\Traits;
4
5
/**
6
 * Trait InflectionClassifyTrait
7
 * @package Nip\Inflector\Traits
8
 *
9
 * @method classify($string)
10
 */
11
trait InflectionClassifyTrait
12
{
13
14
    /**
15
     * Converts lowercase string to underscored camelize class format
16
     *
17
     * @param string $string
18
     * @return string
19
     */
20 7
    protected function doClassify($string)
21
    {
22 7
        $partsNamespace = explode('\\', $string);
23 7
        $return = [];
24 7
        foreach ($partsNamespace as $partNamespace) {
25 7
            $parts = explode("-", $partNamespace);
26 7
            $parts = array_map([$this, "camelize"], $parts);
27
28 7
            $return[] = implode("_", $parts);
29
        }
30 7
        return implode('\\', $return);
31
    }
32
}
33