Test Failed
Push — develop ( d51f40...b19cea )
by nguereza
03:33
created

EventInfo   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 17
c 1
b 0
f 1
dl 0
loc 94
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getName() 0 2 1
A setStop() 0 3 1
A isStop() 0 2 1
A setPayload() 0 3 1
A isReturnBack() 0 2 1
A getPayload() 0 2 1
1
<?php
2
    defined('ROOT_PATH') or exit('Access denied');
3
    /**
4
     * TNH Framework
5
     *
6
     * A simple PHP framework using HMVC architecture
7
     *
8
     * This content is released under the MIT License (MIT)
9
     *
10
     * Copyright (c) 2017 TNH Framework
11
     *
12
     * Permission is hereby granted, free of charge, to any person obtaining a copy
13
     * of this software and associated documentation files (the "Software"), to deal
14
     * in the Software without restriction, including without limitation the rights
15
     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
     * copies of the Software, and to permit persons to whom the Software is
17
     * furnished to do so, subject to the following conditions:
18
     *
19
     * The above copyright notice and this permission notice shall be included in all
20
     * copies or substantial portions of the Software.
21
     *
22
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
     * SOFTWARE.
29
     */
30
31
    /**
32
     * This class represent the event detail to dispatch to correspond listener
33
     */
34
    class EventInfo {
35
		
36
        /**
37
         * The event name
38
         * @var string
39
         */
40
        private $name;
41
42
        /**
43
         * The event data to send to the listeners
44
         * @var mixed
45
         */
46
        private $payload;
47
48
        /**
49
         * If the listeners need return the event after treatment or not, false means no need
50
         * return true need return the event. 
51
         * @var boolean
52
         */
53
        private $returnBack;
54
55
        /**
56
         * This variable indicates if need stop the event propagation
57
         * @var boolean
58
         */
59
        private $stop;
60
		
61
        public function __construct($name, $payload = array(), $returnBack = false, $stop = false) {
62
            $this->name = $name;
63
            $this->payload = $payload;
64
            $this->returnBack = $returnBack;
65
            $this->stop = $stop;
66
        }
67
68
        /**
69
         * Return the name of the event
70
         * 
71
         * @return string
72
         */
73
        public function getName() {
74
            return $this->name;
75
        }
76
77
       
78
        /**
79
         * Return the payload for this event
80
         * 
81
         * @return mixed
82
         */
83
        public function getPayload() {
84
            return $this->payload;
85
        }
86
87
        /**
88
         * Set the event payload
89
         * 
90
         * @param mixed $payload the data for this event
91
         *
92
         * @return object the current instance
93
         */
94
        public function setPayload($payload) {
95
            $this->payload = $payload;
96
            return $this;
97
        }
98
99
        /**
100
         * If we need return the event instance 
101
         * back after processing by each listener
102
         * 
103
         * @return boolean
104
         */
105
        public function isReturnBack() {
106
            return $this->returnBack;
107
        }
108
109
        /**
110
         * If we need stop the event propagation to listeners
111
         *  
112
         * @return boolean
113
         */
114
        public function isStop() {
115
            return $this->stop;
116
        }
117
118
        /**
119
         * Set the event stop status
120
         * 
121
         * @param boolean $stop the status value
122
         *
123
         * @return object the current instance
124
         */
125
        public function setStop($stop) {
126
            $this->stop = $stop;
127
            return $this;
128
        }
129
}
130