Completed
Push — master ( 720abf...ab493c )
by WEBEWEB
01:12
created

AbstractEvent   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 1
dl 0
loc 94
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getEntity() 0 3 1
A getRequest() 0 3 1
A getResponse() 0 3 1
A setEntity() 0 4 1
A setRequest() 0 4 1
A setResponse() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the haveibeenpwned-bundle package.
5
 *
6
 * (c) 2019 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\HaveIBeenPwnedBundle\Event;
13
14
use WBW\Bundle\CoreBundle\Event\AbstractEvent as BaseEvent;
15
use WBW\Library\HaveIBeenPwned\Entity\HaveIBeenPwnedEntityInterface;
16
use WBW\Library\HaveIBeenPwned\Model\AbstractRequest;
17
use WBW\Library\HaveIBeenPwned\Model\AbstractResponse;
18
19
/**
20
 * Abstract event.
21
 *
22
 * @author webeweb <https://github.com/webeweb/>
23
 * @package WBW\Bundle\HaveIBeenPwnedBundle\Event
24
 * @abstract
25
 */
26
abstract class AbstractEvent extends BaseEvent {
27
28
    /**
29
     * Entity.
30
     *
31
     * @var HaveIBeenPwnedEntityInterface
32
     */
33
    private $entity;
34
35
    /**
36
     * Request.
37
     *
38
     * @var AbstractRequest
39
     */
40
    private $request;
41
42
    /**
43
     * Response.
44
     *
45
     * @var AbstractResponse
46
     */
47
    private $response;
48
49
    /**
50
     * Constructor.
51
     *
52
     * @param string $eventName The event name.
53
     * @param HaveIBeenPwnedEntityInterface|null $entity The entity.
54
     */
55
    protected function __construct($eventName, HaveIBeenPwnedEntityInterface $entity = null) {
56
        parent::__construct($eventName);
57
        $this->setEntity($entity);
58
    }
59
60
    /**
61
     * Get the entity.
62
     *
63
     * @return HaveIBeenPwnedEntityInterface Returns the entity.
64
     */
65
    protected function getEntity() {
66
        return $this->entity;
67
    }
68
69
    /**
70
     * Get the request.
71
     *
72
     * @return AbstractRequest Returns the request.
73
     */
74
    protected function getRequest() {
75
        return $this->request;
76
    }
77
78
    /**
79
     * Get the response.
80
     *
81
     * @return AbstractResponse Returns the response.
82
     */
83
    protected function getResponse() {
84
        return $this->response;
85
    }
86
87
    /**
88
     * Set the entity.
89
     *
90
     * @param HaveIBeenPwnedEntityInterface|null $entity The entity.
91
     * @return AbstractEvent Returns this event.
92
     */
93
    protected function setEntity(HaveIBeenPwnedEntityInterface $entity = null) {
94
        $this->entity = $entity;
95
        return $this;
96
    }
97
98
    /**
99
     * Set the request.
100
     *
101
     * @param AbstractRequest $request The request.
102
     * @return AbstractEvent Returns this event.
103
     */
104
    public function setRequest(AbstractRequest $request) {
105
        $this->request = $request;
106
        return $this;
107
    }
108
109
    /**
110
     * Set the response.
111
     *
112
     * @param AbstractResponse $response The response.
113
     * @return AbstractEvent Returns this event.
114
     */
115
    public function setResponse(AbstractResponse $response) {
116
        $this->response = $response;
117
        return $this;
118
    }
119
}
120