Passed
Branch master (bf85d9)
by Johannes
05:40
created

AbstractVisitor   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 41
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A prepare() 0 3 1
A __construct() 0 5 1
A getElementType() 0 10 4
1
<?php
2
3
/*
4
 * Copyright 2016 Johannes M. Schmitt <[email protected]>
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace JMS\Serializer;
20
21
use JMS\Serializer\Accessor\AccessorStrategyInterface;
22
use JMS\Serializer\Accessor\DefaultAccessorStrategy;
23
use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
24
25
abstract class AbstractVisitor
26
{
27
    /**
28
     * @var AccessorStrategyInterface
29
     */
30
    protected $accessor;
31
32
    /**
33
     * @var GraphNavigatorInterface
34
     */
35
    protected $navigator;
36
    /**
37
     * @var Context
38
     */
39
    protected $context;
40
41 298
    public function __construct(GraphNavigatorInterface $navigator, AccessorStrategyInterface $accessorStrategy, Context $context)
42
    {
43 298
        $this->navigator = $navigator;
44 298
        $this->accessor = $accessorStrategy;
45 298
        $this->context = $context;
46 298
    }
47
48 147
    public function prepare($data)
49
    {
50 147
        return $data;
51
    }
52
53
    /**
54
     * @param array $typeArray
55
     */
56 105
    protected function getElementType($typeArray)
57
    {
58 105
        if (false === isset($typeArray['params'][0])) {
59 55
            return null;
60
        }
61
62 53
        if (isset($typeArray['params'][1]) && \is_array($typeArray['params'][1])) {
63 25
            return $typeArray['params'][1];
64
        } else {
65 37
            return $typeArray['params'][0];
66
        }
67
    }
68
}
69