AbstractSeparatorNamingStrategy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 26
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A doConvert() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the Ivory Serializer package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\Serializer\Naming;
13
14
/**
15
 * @author GeLo <[email protected]>
16
 */
17
class AbstractSeparatorNamingStrategy extends AbstractNamingStrategy
18
{
19
    /**
20
     * @var string
21
     */
22
    private $separator;
23
24
    /**
25
     * @param string $separator
26
     */
27 108
    public function __construct($separator)
28
    {
29 108
        $this->separator = $separator;
30 108
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 120
    protected function doConvert($name)
36
    {
37 120
        $name = str_replace(['--', '__', '  '], ' ', $name);
38 120
        $name = lcfirst(str_replace(['-', '_', ' '], $this->separator, $name));
39
40 120
        return strtolower(preg_replace('/([A-Z])/', $this->separator.'$1', $name));
41
    }
42
}
43