Failed Conditions
Pull Request — 1.3.x (#71)
by Grégoire
02:19
created

OnClearEventArgs   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 46
ccs 0
cts 16
cp 0
rs 10

4 Methods

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