Completed
Push — master ( baff27...3a9c47 )
by Daniel
02:56
created

SerializerFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 23
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 1
1
<?php
2
/**
3
 * This file is part of the Commander project.
4
 *
5
 * @author Daniel Schröder <[email protected]>
6
 */
7
8
namespace GravityMedia\Commander\Config;
9
10
use Interop\Container\ContainerInterface;
11
use Interop\Container\Exception\ContainerException;
12
use Symfony\Component\Serializer\Encoder\JsonEncoder;
13
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
14
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
15
use Zend\ServiceManager\Exception\ServiceNotFoundException;
16
use Zend\ServiceManager\Factory\FactoryInterface;
17
18
/**
19
 * Config serializer factory class.
20
 *
21
 * @package GravityMedia\Commander\Serializer
22
 */
23
class SerializerFactory implements FactoryInterface
24
{
25
    /**
26
     * Create config serializer object.
27
     *
28
     * @param  ContainerInterface $container
29
     * @param  string             $requestedName
30
     * @param  null|array         $options
31
     *
32
     * @return Serializer
33
     *
34
     * @throws ServiceNotFoundException if unable to resolve the service.
35
     * @throws ServiceNotCreatedException if an exception is raised when creating a service.
36
     * @throws ContainerException if any other error occurs
37
     */
38 2
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
39
    {
40 2
        $normalizers = [new GetSetMethodNormalizer()];
41 2
        $encoders = [new JsonEncoder()];
42
43 2
        return new Serializer($normalizers, $encoders);
44
    }
45
}
46