OnClearEventArgs   A
last analyzed

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