| 1 | <?php |
||
| 11 | class EmailReporter implements ResultReporterInterface |
||
| 12 | { |
||
| 13 | private $container; |
||
| 14 | private $config; |
||
| 15 | |||
| 16 | 6 | public function __construct($container, $config) |
|
| 21 | |||
| 22 | 1 | public function notify(TestResult $result) |
|
| 23 | { |
||
| 24 | 1 | if ($this->config['enabled'] === false) { |
|
| 25 | return; |
||
| 26 | } |
||
| 27 | |||
| 28 | 1 | $recipients = []; |
|
| 29 | |||
| 30 | 1 | foreach ($result->getTest()->getGroup()->getUsers() as $user) { |
|
| 31 | if ($user->shouldBeAlerted($result)) { |
||
| 32 | $recipients[] = $user->getEmail(); |
||
| 33 | } |
||
| 34 | 1 | } |
|
| 35 | |||
| 36 | 1 | $this->sendEmail($result, $recipients); |
|
| 37 | 1 | } |
|
| 38 | |||
| 39 | 1 | private function sendEmail(TestResult $result, array $users) |
|
| 56 | } |
||
| 57 |