AbstractNamingStrategy::convert()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2
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
abstract class AbstractNamingStrategy implements NamingStrategyInterface
18
{
19
    /**
20
     * @var string[]
21
     */
22
    private $names = [];
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 268
    public function convert($name)
28
    {
29 268
        return isset($this->names[$name])
30 164
            ? $this->names[$name]
31 268
            : $this->names[$name] = $this->doConvert($name);
32
    }
33
34
    /**
35
     * @param string $name
36
     *
37
     * @return string
38
     */
39
    abstract protected function doConvert($name);
40
}
41