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

SerializerFactory::createSerializer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
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