Completed
Push — master ( 1856ca...43d45a )
by Eric
03:58
created

AbstractClassMetadataFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getClassMetadata() 0 8 2
fetchClassMetadata() 0 1 ?
1
<?php
2
3
/*
4
 * This file is part of the Ivory Serializer package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\Serializer\Mapping\Factory;
13
14
use Ivory\Serializer\Mapping\ClassMetadataInterface;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19
abstract class AbstractClassMetadataFactory implements ClassMetadataFactoryInterface
20
{
21
    /**
22
     * @var ClassMetadataInterface[]
23
     */
24
    private $classMetadatas = [];
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getClassMetadata($class)
30
    {
31
        if (array_key_exists($class, $this->classMetadatas)) {
32
            return $this->classMetadatas[$class];
33
        }
34
35
        return $this->classMetadatas[$class] = $this->fetchClassMetadata($class);
36
    }
37
38
    /**
39
     * @param string $class
40
     *
41
     * @return ClassMetadataInterface|null
42
     */
43
    abstract protected function fetchClassMetadata($class);
44
}
45