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.
Completed
Push — master ( b8c8ea...fccb8a )
by Rémi
02:40
created

HydratorFactory::getHydratorClassName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 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 12
    public function __construct($cacheDir, $generateProxies = false)
27
    {
28 12
        $this->cacheDir = $cacheDir;
29 12
        $this->generateProxies = $generateProxies;
30 12
    }
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