Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| AbstractDacEvent | |
0.00% |
0 / 12 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| jsonSerialize | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| getUserUri | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getResourceUri | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPrivilege | |
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) 2020-2023 (original work) Open Assessment Technologies SA. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoDacSimple\model\event; |
| 23 | |
| 24 | use JsonSerializable; |
| 25 | use oat\oatbox\event\Event; |
| 26 | |
| 27 | abstract class AbstractDacEvent implements Event, JsonSerializable |
| 28 | { |
| 29 | /** @var string */ |
| 30 | protected $userUri; |
| 31 | /** @var string */ |
| 32 | protected $resourceUri; |
| 33 | /** @var string[] */ |
| 34 | protected $privilege; |
| 35 | |
| 36 | /** |
| 37 | * @param string $userUri |
| 38 | * @param string $resourceUri |
| 39 | * @param string[] $privilege |
| 40 | */ |
| 41 | public function __construct(string $userUri, string $resourceUri, array $privilege) |
| 42 | { |
| 43 | $this->userUri = $userUri; |
| 44 | $this->resourceUri = $resourceUri; |
| 45 | $this->privilege = $privilege; |
| 46 | } |
| 47 | |
| 48 | |
| 49 | /** |
| 50 | * Return a unique name for this event |
| 51 | * @see \oat\oatbox\event\Event::getName() |
| 52 | */ |
| 53 | public function getName() |
| 54 | { |
| 55 | return static::class; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Specify data which should be serialized to JSON |
| 60 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
| 61 | * @return mixed data which can be serialized by <b>json_encode</b>, |
| 62 | * which is a value of any type other than a resource. |
| 63 | * @since 5.4.0 |
| 64 | */ |
| 65 | public function jsonSerialize() |
| 66 | { |
| 67 | return [ |
| 68 | 'userUri' => $this->userUri, |
| 69 | 'accessUri' => $this->resourceUri, |
| 70 | 'privilege' => $this->privilege |
| 71 | ]; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * @return string |
| 76 | */ |
| 77 | public function getUserUri(): string |
| 78 | { |
| 79 | return $this->userUri; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * @return string |
| 84 | */ |
| 85 | public function getResourceUri(): string |
| 86 | { |
| 87 | return $this->resourceUri; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * @return string[] |
| 92 | */ |
| 93 | public function getPrivilege(): array |
| 94 | { |
| 95 | return $this->privilege; |
| 96 | } |
| 97 | } |