Completed
Pull Request — 1.4.x (#106)
by Grégoire
02:25
created

TestClassMetadataFactory::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\Persistence\Mapping;
6
7
use Doctrine\Persistence\Mapping\AbstractClassMetadataFactory;
8
use Doctrine\Persistence\Mapping\ClassMetadata;
9
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
10
use Doctrine\Persistence\Mapping\ReflectionService;
11
12
class TestClassMetadataFactory extends AbstractClassMetadataFactory
13
{
14
    /** @var MappingDriver */
15
    public $driver;
16
17
    /** @var ClassMetadata|null */
18
    public $metadata;
19
20
    /** @var callable|null */
21
    public $fallbackCallback;
22
23
    public function __construct(MappingDriver $driver, ?ClassMetadata $metadata)
24
    {
25
        $this->driver   = $driver;
26
        $this->metadata = $metadata;
27
    }
28
29
    /**
30
     * @param string[] $nonSuperclassParents
31
     */
32
    protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonSuperclassParents)
33
    {
34
    }
35
36
    protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
37
    {
38
        return __NAMESPACE__ . '\\' . $simpleClassName;
39
    }
40
41
    protected function initialize()
42
    {
43
    }
44
45
    protected function newClassMetadataInstance($className)
46
    {
47
        return $this->metadata;
48
    }
49
50
    protected function getDriver()
51
    {
52
        return $this->driver;
53
    }
54
55
    protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService)
56
    {
57
    }
58
59
    protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService)
60
    {
61
    }
62
63
    protected function isEntity(ClassMetadata $class)
64
    {
65
        return true;
66
    }
67
68
    protected function onNotFoundMetadata($className)
69
    {
70
        if (! $this->fallbackCallback) {
71
            return null;
72
        }
73
74
        return ($this->fallbackCallback)();
75
    }
76
77
    public function isTransient($class)
78
    {
79
        $name = $this->metadata->getName();
0 ignored issues
show
Bug introduced by
The method getName() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

79
        /** @scrutinizer ignore-call */ 
80
        $name = $this->metadata->getName();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
80
81
        return $class !== $name;
82
    }
83
}
84