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