| Conditions | 6 |
| Paths | 10 |
| Total Lines | 20 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 6.6829 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 31 | public function __construct(mgd_exception $e, $id) |
|
| 20 | { |
||
| 21 | 31 | if ($id !== null) { |
|
| 22 | 31 | if ($e->getCode() === MGD_ERR_NOT_EXISTS) { |
|
| 23 | 19 | $code = MIDCOM_ERRNOTFOUND; |
|
| 24 | 19 | $message = "The object with identifier {$id} was not found."; |
|
| 25 | 14 | } elseif ($e->getCode() == MGD_ERR_ACCESS_DENIED) { |
|
| 26 | $code = MIDCOM_ERRFORBIDDEN; |
||
| 27 | $message = midcom::get()->i18n->get_string('access denied', 'midcom'); |
||
| 28 | 14 | } elseif ($e->getCode() == MGD_ERR_OBJECT_DELETED) { |
|
| 29 | $code = MIDCOM_ERRNOTFOUND; |
||
| 30 | $message = "The object with identifier {$id} was deleted."; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | //If other options fail, go for the server error |
||
| 34 | 31 | if (!isset($code)) { |
|
| 35 | 14 | $code = MIDCOM_ERRCRIT; |
|
| 36 | 14 | $message = $e->getMessage(); |
|
| 37 | } |
||
| 38 | 31 | parent::__construct($message, $code); |
|
|
|
|||
| 39 | 31 | } |
|
| 45 | } |