Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
56.25% |
9 / 16 |
|
44.44% |
4 / 9 |
CRAP | |
0.00% |
0 / 1 |
| LtiAgsException | |
56.25% |
9 / 16 |
|
44.44% |
4 / 9 |
21.13 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| getKey | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| __toString | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAgsClaim | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setAgsClaim | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getRegistration | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setRegistration | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getScore | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setScore | |
100.00% |
2 / 2 |
|
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) 2021 (original work) Open Assessment Technologies SA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | declare(strict_types=1); |
| 23 | |
| 24 | namespace oat\taoLti\models\classes\LtiAgs; |
| 25 | |
| 26 | use common_Exception; |
| 27 | use Exception; |
| 28 | use OAT\Library\Lti1p3Ags\Model\Score\ScoreInterface; |
| 29 | use OAT\Library\Lti1p3Core\Message\Payload\Claim\AgsClaim; |
| 30 | use OAT\Library\Lti1p3Core\Registration\RegistrationInterface; |
| 31 | use Ramsey\Uuid\Uuid; |
| 32 | |
| 33 | final class LtiAgsException extends common_Exception |
| 34 | { |
| 35 | /** |
| 36 | * @var string Unique key to determine error in log |
| 37 | */ |
| 38 | private $key; |
| 39 | |
| 40 | /** @var AgsClaim */ |
| 41 | private $agsClaim = null; |
| 42 | |
| 43 | /** @var RegistrationInterface */ |
| 44 | private $registration = null; |
| 45 | |
| 46 | /** @var ScoreInterface */ |
| 47 | private $score = null; |
| 48 | |
| 49 | /** |
| 50 | * LtiException constructor. |
| 51 | * @param null $message |
| 52 | * @param int $code |
| 53 | * @param Exception|null $previous |
| 54 | */ |
| 55 | public function __construct($message = null, $code = 0, Exception $previous = null) |
| 56 | { |
| 57 | if (!is_null($previous)) { |
| 58 | $message .= ' ' . $previous->getMessage(); |
| 59 | } |
| 60 | parent::__construct($message, $code, $previous); |
| 61 | } |
| 62 | |
| 63 | public function getKey(): string |
| 64 | { |
| 65 | if (!isset($this->key)) { |
| 66 | $this->key = Uuid::uuid4()->toString(); |
| 67 | } |
| 68 | |
| 69 | return $this->key; |
| 70 | } |
| 71 | |
| 72 | public function __toString(): string |
| 73 | { |
| 74 | return '[key ' . $this->getKey() . '] ' . parent::__toString(); |
| 75 | } |
| 76 | |
| 77 | public function getAgsClaim(): ?AgsClaim |
| 78 | { |
| 79 | return $this->agsClaim; |
| 80 | } |
| 81 | |
| 82 | public function setAgsClaim(?AgsClaim $agsClaim): self |
| 83 | { |
| 84 | $this->agsClaim = $agsClaim; |
| 85 | |
| 86 | return $this; |
| 87 | } |
| 88 | |
| 89 | public function getRegistration(): ?RegistrationInterface |
| 90 | { |
| 91 | return $this->registration; |
| 92 | } |
| 93 | |
| 94 | public function setRegistration(?RegistrationInterface $registration): self |
| 95 | { |
| 96 | $this->registration = $registration; |
| 97 | |
| 98 | return $this; |
| 99 | } |
| 100 | |
| 101 | public function getScore(): ?ScoreInterface |
| 102 | { |
| 103 | return $this->score; |
| 104 | } |
| 105 | |
| 106 | public function setScore(?ScoreInterface $score): self |
| 107 | { |
| 108 | $this->score = $score; |
| 109 | |
| 110 | return $this; |
| 111 | } |
| 112 | } |