AbstractClassMetadataFactory::fetchClassMetadata()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
ccs 0
cts 0
cp 0
nc 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 1112
    public function getClassMetadata($class)
30
    {
31 1112
        return array_key_exists($class, $this->classMetadatas)
32 140
            ? $this->classMetadatas[$class]
33 1112
            : $this->classMetadatas[$class] = $this->fetchClassMetadata($class);
34
    }
35
36
    /**
37
     * @param string $class
38
     *
39
     * @return ClassMetadataInterface|null
40
     */
41
    abstract protected function fetchClassMetadata($class);
42
}
43