GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

HydratorFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 54
rs 10
c 0
b 0
f 0
ccs 13
cts 13
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getHydrator() 0 6 1
A getHydratorClassName() 0 8 1
1
<?php
2
3
namespace RemiSan\Serializer\Hydrator;
4
5
use GeneratedHydrator\Configuration;
6
use Zend\Hydrator\HydratorInterface;
7
8
class HydratorFactory
9
{
10
    /**
11
     * @var string
12
     */
13
    private $cacheDir;
14
15
    /**
16
     * @var bool
17
     */
18
    private $generateProxies;
19
20
    /**
21
     * Constructor.
22
     *
23
     * @param string $cacheDir
24
     * @param bool   $generateProxies
25
     */
26 27
    public function __construct($cacheDir, $generateProxies = false)
27
    {
28 27
        $this->cacheDir = $cacheDir;
29 27
        $this->generateProxies = $generateProxies;
30 27
    }
31
32
    /**
33
     * Gets an hydrator instance for the given class.
34
     *
35
     * @param string $fqcn
36
     *
37
     * @return HydratorInterface
38
     */
39 9
    public function getHydrator($fqcn)
40
    {
41 9
        $hydratorClass = $this->getHydratorClassName($fqcn);
42
43 9
        return new $hydratorClass();
44
    }
45
46
    /**
47
     * Gets the hydrator class name.
48
     *
49
     * @param string $fqcn
50
     *
51
     * @return string
52
     */
53 12
    public function getHydratorClassName($fqcn)
54
    {
55 12
        $config = new Configuration($fqcn);
56 12
        $config->setAutoGenerateProxies($this->generateProxies);
57 12
        $config->setGeneratedClassesTargetDir($this->cacheDir);
58
59 12
        return $config->createFactory()->getHydratorClass();
60 2
    }
61
}
62