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

AbstractClassMetadataFactory::getClassMetadata()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 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