Failed Conditions
Push — master ( 3a6c46...2fbe69 )
by Luís
36s queued 11s
created

OnClearEventArgs::clearsAllEntities()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Doctrine\Persistence\Event;
4
5
use Doctrine\Common\EventArgs;
6
use Doctrine\Persistence\ObjectManager;
7
8
/**
9
 * Provides event arguments for the onClear event.
10
 */
11
class OnClearEventArgs extends EventArgs
12
{
13
    /** @var ObjectManager */
14
    private $objectManager;
15
16
    /** @var string|null */
17
    private $entityClass;
18
19
    /**
20
     * @param ObjectManager $objectManager The object manager.
21
     * @param string|null   $entityClass   The optional entity class.
22
     */
23
    public function __construct($objectManager, $entityClass = null)
24
    {
25
        $this->objectManager = $objectManager;
26
        $this->entityClass   = $entityClass;
27
    }
28
29
    /**
30
     * Retrieves the associated ObjectManager.
31
     *
32
     * @return ObjectManager
33
     */
34
    public function getObjectManager()
35
    {
36
        return $this->objectManager;
37
    }
38
39
    /**
40
     * Returns the name of the entity class that is cleared, or null if all are cleared.
41
     *
42
     * @return string|null
43
     */
44
    public function getEntityClass()
45
    {
46
        return $this->entityClass;
47
    }
48
49
    /**
50
     * Returns whether this event clears all entities.
51
     *
52
     * @return bool
53
     */
54
    public function clearsAllEntities()
55
    {
56
        return $this->entityClass === null;
57
    }
58
}
59