Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
90.00% |
9 / 10 |
|
90.00% |
9 / 10 |
CRAP | |
0.00% |
0 / 1 |
| WebhookTaskParams | |
90.00% |
9 / 10 |
|
90.00% |
9 / 10 |
10.10 | |
0.00% |
0 / 1 |
| getEventName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getEventId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getTriggeredTimestamp | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getEventData | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getWebhookConfigId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getRetryMax | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| increaseRetryCount | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isMaxRetryCountReached | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getRetryCount | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| responseValidation | |
100.00% |
1 / 1 |
|
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) 2019 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | namespace oat\tao\model\webhooks\task; |
| 22 | |
| 23 | use ArrayObject; |
| 24 | |
| 25 | /** |
| 26 | * Traversable object with described keys which could be passed to task as metadata |
| 27 | */ |
| 28 | class WebhookTaskParams extends ArrayObject |
| 29 | { |
| 30 | public const EVENT_NAME = 'eventName'; |
| 31 | public const EVENT_ID = 'eventId'; |
| 32 | public const TRIGGERED_TIMESTAMP = 'triggeredTimestamp'; |
| 33 | public const EVENT_DATA = 'eventData'; |
| 34 | public const WEBHOOK_CONFIG_ID = 'webhookConfigId'; |
| 35 | public const RETRY_MAX = 'retryMax'; |
| 36 | public const RETRY_COUNT = 'retryCount'; |
| 37 | public const RESPONSE_VALIDATION = 'responseValidation'; |
| 38 | |
| 39 | /** |
| 40 | * @return string |
| 41 | */ |
| 42 | public function getEventName() |
| 43 | { |
| 44 | return $this[self::EVENT_NAME]; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * @return string |
| 49 | */ |
| 50 | public function getEventId() |
| 51 | { |
| 52 | return $this[self::EVENT_ID]; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @return int |
| 57 | */ |
| 58 | public function getTriggeredTimestamp() |
| 59 | { |
| 60 | return $this[self::TRIGGERED_TIMESTAMP]; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * @return array |
| 65 | */ |
| 66 | public function getEventData() |
| 67 | { |
| 68 | return $this[self::EVENT_DATA]; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * @return string |
| 73 | */ |
| 74 | public function getWebhookConfigId() |
| 75 | { |
| 76 | return $this[self::WEBHOOK_CONFIG_ID]; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * @return int |
| 81 | */ |
| 82 | public function getRetryMax() |
| 83 | { |
| 84 | return $this[self::RETRY_MAX]; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * increase retry counter |
| 89 | */ |
| 90 | public function increaseRetryCount() |
| 91 | { |
| 92 | $this[self::RETRY_COUNT]++; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Check if retry counter reached max retry value |
| 97 | * @return bool |
| 98 | */ |
| 99 | public function isMaxRetryCountReached() |
| 100 | { |
| 101 | return $this[self::RETRY_COUNT] >= $this[self::RETRY_MAX]; |
| 102 | } |
| 103 | |
| 104 | public function getRetryCount() |
| 105 | { |
| 106 | return $this[self::RETRY_COUNT]; |
| 107 | } |
| 108 | |
| 109 | public function responseValidation() |
| 110 | { |
| 111 | return $this[self::RESPONSE_VALIDATION]; |
| 112 | } |
| 113 | } |