OnClassMetadataNotFoundEventArgs   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 38
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setFoundMetadata() 0 4 1
A getFoundMetadata() 0 4 1
A getClassName() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ODM\MongoDB\Event;
6
7
use Doctrine\ODM\MongoDB\DocumentManager;
8
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
9
10
/**
11
 * Class that holds event arguments for a `onClassMetadataNotFound` event.
12
 *
13
 * This object is mutable by design, allowing callbacks having access to it to set the
14
 * found metadata in it, and therefore "cancelling" a `onClassMetadataNotFound` event
15
 */
16
final class OnClassMetadataNotFoundEventArgs extends ManagerEventArgs
17
{
18
    /** @var string */
19
    private $className;
20
21
    /** @var ClassMetadata|null */
22
    private $foundMetadata;
23
24 3
    public function __construct(string $className, DocumentManager $dm)
25
    {
26 3
        $this->className = $className;
27
28 3
        parent::__construct($dm);
29 3
    }
30
31 3
    public function setFoundMetadata(?ClassMetadata $classMetadata = null)
32
    {
33 3
        $this->foundMetadata = $classMetadata;
34 3
    }
35
36
    /**
37
     * @return ClassMetadata|null
38
     */
39 3
    public function getFoundMetadata()
40
    {
41 3
        return $this->foundMetadata;
42
    }
43
44
    /**
45
     * Retrieve class name for which a failed metadata fetch attempt was executed
46
     *
47
     * @return string
48
     */
49 3
    public function getClassName()
50
    {
51 3
        return $this->className;
52
    }
53
}
54