Completed
Push — master ( 1967e9...72c193 )
by Matthieu
01:57
created

SerializerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A createSerializer() 0 8 1
1
<?php
2
3
namespace Syncer\Factory;
4
5
use JMS\Serializer\SerializerBuilder;
6
7
/**
8
 * Class SerializerFactory
9
 * @package Syncer\Factory
10
 *
11
 * @author Matthieu Calie <[email protected]>
12
 */
13
class SerializerFactory
14
{
15
    /**
16
     * @var bool
17
     */
18
    private $debug;
19
20
    /**
21
     * @var string
22
     */
23
    private $configDir;
24
25
    /**
26
     * @var string
27
     */
28
    private $cacheDir;
29
30
    /**
31
     * SerializerFactory constructor.
32
     *
33
     * @param bool $debug
34
     * @param string $configDir
35
     * @param string $cacheDir
36
     */
37
    function __construct(bool $debug, string $configDir, string $cacheDir)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
38
    {
39
        $this->debug = $debug;
40
        $this->configDir = $configDir;
41
        $this->cacheDir = $cacheDir;
42
    }
43
44
    /**
45
     * @return \JMS\Serializer\Serializer
46
     */
47
    public function createSerializer()
48
    {
49
        return SerializerBuilder::create()
50
            ->addMetadataDir($this->configDir, 'Syncer\Dto')
51
            ->setCacheDir($this->cacheDir)
52
            ->setDebug($this->debug)
53
            ->build();
54
    }
55
}
56