Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
75.00% |
3 / 4 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| GenericEvent | |
75.00% |
3 / 4 |
|
66.67% |
2 / 3 |
3.14 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getParams | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2015 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\oatbox\event; |
| 23 | |
| 24 | use common_ext_ExtensionsManager; |
| 25 | |
| 26 | /** |
| 27 | * A generic event used for events that are defined by name alone |
| 28 | * |
| 29 | * @author Joel Bout <joel@taotesting.com> |
| 30 | */ |
| 31 | class GenericEvent implements Event |
| 32 | { |
| 33 | /** |
| 34 | * Event name |
| 35 | * |
| 36 | * @var string |
| 37 | */ |
| 38 | private $eventName; |
| 39 | /** |
| 40 | * Parameters of the event |
| 41 | * |
| 42 | * @var array() |
| 43 | */ |
| 44 | private $params; |
| 45 | |
| 46 | /** |
| 47 | * Create a new generic event based on an event name |
| 48 | * with optional parameters |
| 49 | * |
| 50 | * @param string $eventName |
| 51 | * @param array $params |
| 52 | */ |
| 53 | public function __construct($eventName, $params = []) |
| 54 | { |
| 55 | $this->eventName = (string)$eventName; |
| 56 | $this->params = $params; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * (non-PHPdoc) |
| 61 | * @see \oat\oatbox\event\Event::getName() |
| 62 | */ |
| 63 | public function getName() |
| 64 | { |
| 65 | return $this->eventName; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Get parameters |
| 70 | * @return array |
| 71 | */ |
| 72 | public function getParams() |
| 73 | { |
| 74 | return $this->params; |
| 75 | } |
| 76 | } |