Completed
Push — master ( 111bcd...99ca87 )
by Andrey
26:30
created

CamelCaseNamingStrategyFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createService() 0 16 3
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/jms-serializer-module
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\JmsSerializerModule\NamingStrategy;
7
8
use JMS\Serializer\Naming\CamelCaseNamingStrategy;
9
use Zend\ServiceManager\FactoryInterface;
10
use Zend\ServiceManager\MutableCreationOptionsInterface;
11
use Zend\ServiceManager\MutableCreationOptionsTrait;
12
use Zend\ServiceManager\ServiceLocatorInterface;
13
14
/**
15
 * Class CamelCaseNamingStrategyFactory
16
 *
17
 * @package Nnx\JmsSerializerModule\NamingStrategy
18
 */
19
class CamelCaseNamingStrategyFactory implements FactoryInterface, MutableCreationOptionsInterface
20
{
21
    use MutableCreationOptionsTrait;
22
23
    /**
24
     * @inheritdoc
25
     *
26
     * @param ServiceLocatorInterface $serviceLocator
27
     *
28
     * @return CamelCaseNamingStrategy
29
     */
30
    public function createService(ServiceLocatorInterface $serviceLocator)
31
    {
32
        $creationOptions = $this->getCreationOptions();
33
34
        $separator = '_';
35
        if (array_key_exists('separator', $creationOptions)) {
36
            $separator = (string)$creationOptions['separator'];
37
        }
38
39
        $lowerCase = true;
40
        if (array_key_exists('lowerCase', $creationOptions)) {
41
            $lowerCase = (boolean)$creationOptions['lowerCase'];
42
        }
43
44
        return new CamelCaseNamingStrategy($separator, $lowerCase);
45
    }
46
}
47