Test Failed
Push — master ( 13dcda...44dfad )
by Antonio Carlos
04:33
created

src/Listeners/NotifyHealthIssue.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace PragmaRX\Health\Listeners;
4
5
use Notification;
6
use PragmaRX\Health\Events\RaiseHealthIssue;
7
use PragmaRX\Health\Notifications\HealthStatus;
8
9
class NotifyHealthIssue
10
{
11
    /**
12
     * @return static
13
     */
14
    private function getNotifiableUsers()
15
    {
16
        return collect(config('health.notifications.users.emails'))->map(
17
            function ($item) {
18
                $model = instantiate(
19
                    config('health.notifications.users.model')
20
                );
21
22
                $model->email = $item;
23
24
                return $model;
25
            }
26
        );
27
    }
28
29
    /**
30
     * Handle the event.
31
     *
32
     * @param  RaiseHealthIssue  $event
33
     * @return void
34
     */
35
    public function handle(RaiseHealthIssue $event)
36
    {
37
        try {
38
            Notification::send(
39
                $this->getNotifiableUsers(),
40
                new HealthStatus($event->failure, $event->channel)
41
            );
42
        } catch (\Exception $exception) {
43
            // do nothing
44
        } catch (\ErrorException $exception) {
0 ignored issues
show
The class ErrorException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
45
            // do nothing
46
        }
47
    }
48
}
49