Completed
Push — master ( 3a75c3...4b4c57 )
by Rafael
04:18
created

CamelCaseNamingStrategy::transformName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
/**
4
 * LICENSE: This file is subject to the terms and conditions defined in
5
 * file 'LICENSE', which is part of this source code package.
6
 *
7
 * @copyright 2016 Copyright(c) - All rights reserved.
8
 */
9
10
namespace Rafrsr\LibArray2Object\Naming;
11
12
use Doctrine\Common\Util\Inflector;
13
14
/**
15
 * Transform property name from "property_name" -> "propertyName"
16
 */
17
class CamelCaseNamingStrategy implements NamingStrategyInterface
18
{
19
    /**
20
     * @var bool
21
     */
22
    protected $ucFirst;
23
24
    /**
25
     * CamelCaseNamingStrategy constructor.
26
     *
27
     * @param boolean $ucFirst
28
     */
29
    public function __construct($ucFirst = false)
30
    {
31
        $this->ucFirst = $ucFirst;
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37
    public function transformName($name)
38
    {
39
        if ($this->ucFirst) {
40
            return Inflector::classify($name);
41
        } else {
42
            return Inflector::camelize($name);
43
        }
44
    }
45
}