| Conditions | 7 |
| Paths | 21 |
| Total Lines | 28 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | public function __construct($errors = [], $status = 0 ) |
||
| 9 | { |
||
| 10 | $message = ""; |
||
| 11 | |||
| 12 | $this->errors = $errors; |
||
| 13 | |||
| 14 | if (!empty($errors)){ |
||
| 15 | $error = array_shift($errors); |
||
| 16 | |||
| 17 | if (isset($error->title)){ |
||
| 18 | $message = $error->title; |
||
| 19 | } |
||
| 20 | |||
| 21 | if (isset($error->detail)){ |
||
| 22 | $message .= (empty($message)) ? $error->detail : ": $error->detail"; |
||
| 23 | } |
||
| 24 | } |
||
| 25 | |||
| 26 | if (empty($message)){ |
||
| 27 | $message = "API Server Responded with error"; |
||
| 28 | |||
| 29 | if ($status){ |
||
| 30 | $message .= " $status"; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | // make sure everything is assigned properly |
||
| 35 | parent::__construct($message, $status); |
||
| 36 | } |
||
| 44 |