| Conditions | 2 |
| Paths | 2 |
| Total Lines | 32 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 26 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 39 | 6 | public function alert(Alert $alert) |
|
| 40 | { |
||
| 41 | 6 | $message = new Message(); |
|
| 42 | |||
| 43 | 6 | if ($alert->isOverUsed()) { |
|
| 44 | 3 | $color = Message::COLOR_RED; |
|
| 45 | 3 | $text = sprintf( |
|
| 46 | 3 | 'Server at full capacity! Command: %s | CPU: %s | Load: %s | Required: %s | Running: %s', |
|
| 47 | 3 | (string) $alert->getCommandInput(), |
|
| 48 | 3 | $alert->getCpuUsage(), |
|
| 49 | 3 | $alert->getLoadAverage(), |
|
| 50 | 3 | $alert->getLeftOver(), |
|
| 51 | 3 | $alert->getRunningProcesses() |
|
| 52 | 3 | ); |
|
| 53 | 3 | } else { |
|
| 54 | 3 | $color = Message::COLOR_YELLOW; |
|
| 55 | 3 | $text = sprintf( |
|
| 56 | 3 | 'Server under used. You may take it down! Command: %s | CPU: %s | Load: %s', |
|
| 57 | 3 | (string) $alert->getCommandInput(), |
|
| 58 | 3 | $alert->getCpuUsage(), |
|
| 59 | 3 | $alert->getLoadAverage() |
|
| 60 | 3 | ); |
|
| 61 | } |
||
| 62 | |||
| 63 | $message |
||
| 64 | 6 | ->setColor($color) |
|
| 65 | 6 | ->setNotify(true) |
|
| 66 | 6 | ->setMessageFormat(Message::FORMAT_TEXT) |
|
| 67 | 6 | ->setMessage($text); |
|
| 68 | |||
| 69 | 6 | $this->api->sendRoomNotification($this->room, $message); |
|
| 70 | 6 | } |
|
| 71 | } |
||
| 72 |