Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
97.37% |
37 / 38 |
|
92.31% |
12 / 13 |
CRAP | |
0.00% |
0 / 1 |
| Notification | |
97.37% |
37 / 38 |
|
92.31% |
12 / 13 |
15 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| getStatus | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getRecipient | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getSenderId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getSenderName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMessage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCreatedAt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUpdatedAt | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setStatus | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
2.03 | |||
| setId | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| getTitle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| jsonSerialize | |
100.00% |
12 / 12 |
|
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) 2020 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\tao\model\notification; |
| 23 | |
| 24 | use JsonSerializable; |
| 25 | |
| 26 | /** |
| 27 | * Class Notification |
| 28 | * |
| 29 | * @deprecated This class is used by client only. It will be moved to client specific extension |
| 30 | */ |
| 31 | class Notification implements JsonSerializable |
| 32 | { |
| 33 | public const DEFAULT_STATUS = 0; |
| 34 | |
| 35 | public const CREATED_STATUS = 0; |
| 36 | public const SENDING_STATUS = 1; |
| 37 | public const SENDED_STATUS = 2; |
| 38 | public const READ_STATUS = 3; |
| 39 | public const ARCHIVED_STATUS = 4; |
| 40 | |
| 41 | protected $id; |
| 42 | |
| 43 | protected $status; |
| 44 | |
| 45 | protected $recipient; |
| 46 | |
| 47 | protected $senderId; |
| 48 | |
| 49 | protected $senderName; |
| 50 | |
| 51 | protected $title; |
| 52 | |
| 53 | protected $message; |
| 54 | |
| 55 | protected $createdAt; |
| 56 | |
| 57 | protected $updatedAt; |
| 58 | |
| 59 | public function __construct( |
| 60 | string $userId, |
| 61 | string $title, |
| 62 | string $message, |
| 63 | string $senderId, |
| 64 | string $senderName, |
| 65 | string $id = null, |
| 66 | string $createdAt = null, |
| 67 | string $updatedAt = null, |
| 68 | int $status = 0 |
| 69 | ) { |
| 70 | $this->id = $id; |
| 71 | $this->status = $status; |
| 72 | $this->recipient = $userId; |
| 73 | $this->senderId = $senderId; |
| 74 | $this->senderName = $senderName; |
| 75 | $this->title = $title; |
| 76 | $this->message = $message; |
| 77 | $this->createdAt = $createdAt; |
| 78 | $this->updatedAt = $updatedAt; |
| 79 | } |
| 80 | |
| 81 | public function getStatus(): int |
| 82 | { |
| 83 | return $this->status; |
| 84 | } |
| 85 | |
| 86 | public function getRecipient(): string |
| 87 | { |
| 88 | return $this->recipient; |
| 89 | } |
| 90 | |
| 91 | public function getSenderId(): string |
| 92 | { |
| 93 | return $this->senderId; |
| 94 | } |
| 95 | |
| 96 | public function getSenderName(): string |
| 97 | { |
| 98 | return $this->senderName; |
| 99 | } |
| 100 | |
| 101 | public function getMessage(): string |
| 102 | { |
| 103 | return $this->message; |
| 104 | } |
| 105 | |
| 106 | public function getId(): string |
| 107 | { |
| 108 | return $this->id; |
| 109 | } |
| 110 | |
| 111 | public function getCreatedAt(): int |
| 112 | { |
| 113 | return strtotime($this->createdAt); |
| 114 | } |
| 115 | |
| 116 | public function getUpdatedAt(): int |
| 117 | { |
| 118 | return strtotime($this->updatedAt); |
| 119 | } |
| 120 | |
| 121 | public function setStatus($status): self |
| 122 | { |
| 123 | if (is_int($status)) { |
| 124 | $this->status = $status; |
| 125 | } else { |
| 126 | $this->status = self::DEFAULT_STATUS; |
| 127 | } |
| 128 | $this->updatedAt = date('Y-m-d H:i:s'); |
| 129 | return $this; |
| 130 | } |
| 131 | |
| 132 | public function setId($id): self |
| 133 | { |
| 134 | if ($this->id === null) { |
| 135 | $this->id = $id; |
| 136 | } |
| 137 | return $this; |
| 138 | } |
| 139 | |
| 140 | public function getTitle(): string |
| 141 | { |
| 142 | return $this->title; |
| 143 | } |
| 144 | |
| 145 | public function jsonSerialize(): array |
| 146 | { |
| 147 | return |
| 148 | [ |
| 149 | 'id' => $this->getId(), |
| 150 | 'status' => $this->getStatus(), |
| 151 | 'recipient' => $this->getRecipient(), |
| 152 | 'sender' => $this->getSenderId(), |
| 153 | 'senderName' => $this->getSenderId(), |
| 154 | 'title' => $this->getTitle(), |
| 155 | 'message' => $this->getMessage(), |
| 156 | 'createdAt' => $this->getCreatedAt(), |
| 157 | 'updatedAt' => $this->getUpdatedAt(), |
| 158 | ]; |
| 159 | } |
| 160 | } |