DocumentNotFoundEventArgs::disableException()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ODM\MongoDB\Event;
6
7
use Doctrine\ODM\MongoDB\DocumentManager;
8
9
/**
10
 * Provides event arguments for the documentNotFound event.
11
 */
12
final class DocumentNotFoundEventArgs extends LifecycleEventArgs
13
{
14
    /** @var mixed */
15
    private $identifier;
16
17
    /** @var bool */
18
    private $disableException = false;
19
20
    /**
21
     * @param mixed $identifier
22
     */
23 9
    public function __construct(object $document, DocumentManager $dm, $identifier)
24
    {
25 9
        parent::__construct($document, $dm);
26 9
        $this->identifier = $identifier;
27 9
    }
28
29
    /**
30
     * Retrieve associated identifier.
31
     *
32
     * @return mixed
33
     */
34
    public function getIdentifier()
35
    {
36
        return $this->identifier;
37
    }
38
39
    /**
40
     * Indicates whether the proxy initialization exception is disabled.
41
     */
42 9
    public function isExceptionDisabled() : bool
43
    {
44 9
        return $this->disableException;
45
    }
46
47
    /**
48
     * Disable the throwing of an exception
49
     *
50
     * This method indicates to the proxy initializer that the missing document
51
     * has been handled and no exception should be thrown. This can't be reset.
52
     */
53 1
    public function disableException(bool $disableException = true) : void
54
    {
55 1
        $this->disableException = $disableException;
56 1
    }
57
}
58