Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
55.56% |
5 / 9 |
|
60.00% |
3 / 5 |
CRAP | |
0.00% |
0 / 1 |
| UserCreatedEvent | |
55.56% |
5 / 9 |
|
60.00% |
3 / 5 |
7.19 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| jsonSerialize | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getWebhookEventName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| serializeForWebhook | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 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-2020 (original work) Open Assessment Technologies SA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | declare(strict_types=1); |
| 23 | |
| 24 | namespace oat\tao\model\event; |
| 25 | |
| 26 | use core_kernel_classes_Resource; |
| 27 | use JsonSerializable; |
| 28 | use oat\oatbox\event\Event; |
| 29 | use oat\tao\model\webhooks\WebhookSerializableEventInterface; |
| 30 | |
| 31 | class UserCreatedEvent implements Event, JsonSerializable, WebhookSerializableEventInterface |
| 32 | { |
| 33 | private const WEBHOOK_EVENT_NAME = 'user-created'; |
| 34 | |
| 35 | /** @var string */ |
| 36 | protected $user; |
| 37 | |
| 38 | /** |
| 39 | * @param core_kernel_classes_Resource $user |
| 40 | */ |
| 41 | public function __construct(core_kernel_classes_Resource $user) |
| 42 | { |
| 43 | $this->user = $user; |
| 44 | } |
| 45 | |
| 46 | |
| 47 | /** |
| 48 | * Return a unique name for this event |
| 49 | * @see \oat\oatbox\event\Event::getName() |
| 50 | */ |
| 51 | public function getName() |
| 52 | { |
| 53 | return get_class($this); |
| 54 | } |
| 55 | |
| 56 | public function jsonSerialize(): array |
| 57 | { |
| 58 | return [ |
| 59 | 'uri' => $this->user->getUri(), |
| 60 | ]; |
| 61 | } |
| 62 | |
| 63 | public function getWebhookEventName() |
| 64 | { |
| 65 | return self::WEBHOOK_EVENT_NAME; |
| 66 | } |
| 67 | |
| 68 | public function serializeForWebhook() |
| 69 | { |
| 70 | return [ |
| 71 | 'userId' => $this->user->getUri(), |
| 72 | ]; |
| 73 | } |
| 74 | } |