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

CamelCaseNamingStrategy   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A transformName() 0 8 2
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
}