Event::isCancelled()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Sokil\FraudDetector;
4
5
class Event extends \Symfony\Component\EventDispatcher\Event
6
{
7
    /**
8
     * @var mixed $target target object, on which event is fired
9
     */
10
    private $_target;
11
12
    private $_cancelled = false;
13
14
    /**
15
     * Set target object, on which event is fired
16
     * @param mixed $target
17
     * @return \Sokil\Mongo\Event
18
     */
19
    public function setTarget($target)
20
    {
21
        $this->_target = $target;
22
        return $this;
23
    }
24
25
    /**
26
     * Get target object, on which event is fired
27
     * @return mixed
28
     */
29
    public function getTarget()
30
    {
31
        return $this->_target;
32
    }
33
34
    /**
35
     * Check if operation execution cancelled
36
     */
37
    public function isCancelled()
38
    {
39
        return $this->_cancelled;
40
    }
41
42
    /**
43
     * Cancel related operation execution. If called as beforeInsert
44
     * handler, than insert will be cancelled.
45
     */
46
    public function cancel()
47
    {
48
        $this->_cancelled = true;
49
50
        // propagation already not need
51
        $this->stopPropagation();
52
53
        return $this;
54
    }
55
}