Completed
Pull Request — master (#929)
by Asmir
02:40
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 6
dl 0
loc 15
ccs 7
cts 7
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*
3
 * Copyright 2016 Johannes M. Schmitt <[email protected]>
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
namespace JMS\Serializer\GraphNavigator\Factory;
19
20
use JMS\Serializer\Accessor\AccessorStrategyInterface;
21
use JMS\Serializer\Construction\ObjectConstructorInterface;
22
use JMS\Serializer\EventDispatcher\EventDispatcherInterface;
23
use JMS\Serializer\Expression\ExpressionEvaluatorInterface;
24
use JMS\Serializer\GraphNavigator\DeserializationGraphNavigator;
25
use JMS\Serializer\GraphNavigatorInterface;
26
use JMS\Serializer\Handler\HandlerRegistryInterface;
27
use Metadata\MetadataFactoryInterface;
28
29
final class DeserializationGraphNavigatorFactory implements GraphNavigatorFactoryInterface
30
{
31
32
    /**
33
     * @var MetadataFactoryInterface
34
     */
35
    private $metadataFactory;
36
    /**
37
     * @var HandlerRegistryInterface
38
     */
39
    private $handlerRegistry;
40
    /**
41
     * @var ObjectConstructorInterface
42
     */
43
    private $objectConstructor;
44
    /**
45
     * @var AccessorStrategyInterface
46
     */
47
    private $accessor;
48
    /**
49
     * @var EventDispatcherInterface
50
     */
51
    private $dispatcher;
52
    /**
53
     * @var ExpressionEvaluatorInterface
54
     */
55
    private $expressionEvaluator;
56
57 315
    public function __construct(
58
        MetadataFactoryInterface $metadataFactory,
59
        HandlerRegistryInterface $handlerRegistry,
60
        ObjectConstructorInterface $objectConstructor,
61
        AccessorStrategyInterface $accessor,
62
        EventDispatcherInterface $dispatcher = null,
63
        ExpressionEvaluatorInterface $expressionEvaluator = null
64
    ) {
65
66 315
        $this->metadataFactory = $metadataFactory;
67 315
        $this->handlerRegistry = $handlerRegistry;
68 315
        $this->objectConstructor = $objectConstructor;
69 315
        $this->accessor = $accessor;
70 315
        $this->dispatcher = $dispatcher;
71 315
        $this->expressionEvaluator = $expressionEvaluator;
72 315
    }
73
74 133
    public function getGraphNavigator(): GraphNavigatorInterface
75
    {
76 133
        return new DeserializationGraphNavigator($this->metadataFactory, $this->handlerRegistry, $this->objectConstructor, $this->accessor, $this->dispatcher, $this->expressionEvaluator);
77
    }
78
}
79