Passed
Branch master (bcdbf3)
by Marc
07:06
created
src/Notifications/BaseNotificationTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@
 block discarded – undo
16 16
         /* @var $host \Spatie\ServerMonitor\Models\Host */
17 17
         $host = $event->check->host()->first();
18 18
         $notifications = $host->getCustomProperty('notifications');
19
-        if(!$notifications) {
19
+        if (!$notifications) {
20 20
             return config('server-monitor.notifications.notifications.'.static::class);
21 21
         }
22
-        if(isset($notifications[static::class])) {
22
+        if (isset($notifications[static::class])) {
23 23
             return $notifications[static::class]['channels'];
24 24
         }
25 25
         return [];
Please login to merge, or discard this patch.
src/Notifications/Notifiable.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -5,18 +5,18 @@  discard block
 block discarded – undo
5 5
 
6 6
 class Notifiable extends \Spatie\ServerMonitor\Notifications\Notifiable
7 7
 {
8
-    public function routeNotificationForMail(): ?array
8
+    public function routeNotificationForMail(): ? array
9 9
     {
10 10
         return parent::routeNotificationForMail();
11 11
 
12
-        if($notification = $this->getSpecificConfiguration('mail')) {
12
+        if ($notification = $this->getSpecificConfiguration('mail')) {
13 13
             return $notification;
14 14
         }
15 15
     }
16 16
 
17 17
     public function routeNotificationForSlack(): ?string
18 18
     {
19
-        if($notification = $this->getSpecificConfiguration('slack')) {
19
+        if ($notification = $this->getSpecificConfiguration('slack')) {
20 20
             return $notification;
21 21
         }
22 22
         return parent::routeNotificationForSlack();
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 
32 32
     private function getSpecificConfiguration($type) {
33 33
         $notifications = $this->getHost()->getCustomProperty('notifications');
34
-        if($notifications) {
35
-            if(!isset($notifications['configuration'][$type])) {
34
+        if ($notifications) {
35
+            if (!isset($notifications['configuration'][$type])) {
36 36
                 return null;
37 37
             }
38
-            if(count($notifications['configuration'][$type]) == 1) {
38
+            if (count($notifications['configuration'][$type]) == 1) {
39 39
                 $configuration = config('server-monitor-plugin-notification-by-host.notifications.channels.'.$type);
40 40
                 return $notifications['configuration'][$type][array_keys($configuration)[0]];
41 41
             }
Please login to merge, or discard this patch.
src/Commands/ListNotifications.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
         $hosts = $this->determineHostModelClass()::all();
35 35
         if ($hostName = $this->option('host')) {
36
-            $hosts = $hosts->filter(function (Host $host) use ($hostName) {
36
+            $hosts = $hosts->filter(function(Host $host) use ($hostName) {
37 37
                 return $host->name === $hostName;
38 38
             });
39 39
         }
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
         $rows = [];
51 51
         $first = true;
52 52
         foreach ($hosts as $host) {
53
-            if(!$first) {
53
+            if (!$first) {
54 54
                 $rows[] = new TableSeparator();
55 55
             }
56 56
             /* @var $host Host */
57 57
             $rows[] = [$host->name];
58 58
 
59 59
             $hostNotifications = $host->getCustomProperty('notifications');
60
-            if($hostNotifications) {
60
+            if ($hostNotifications) {
61 61
                 $rows = $this->displayCustomNotification($hostNotifications, $rows);
62 62
             }
63 63
             else {
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
             $rows[] = [''];
74 74
             $temp = [implode("\n", str_split($notification, 50))];
75 75
             foreach ($this->channels as $type => $channel) {
76
-                if(isset($hostNotifications[$notification]) && array_search($type, $hostNotifications[$notification]['channels']) !== false) {
77
-                    if(isset($hostNotifications['configuration'][$type])) {
76
+                if (isset($hostNotifications[$notification]) && array_search($type, $hostNotifications[$notification]['channels']) !== false) {
77
+                    if (isset($hostNotifications['configuration'][$type])) {
78 78
                         $configurationList = [];
79 79
                         foreach ($hostNotifications['configuration'][$type] as $configurationAttribut => $configurationValue) {
80
-                            $configurationList[] = $configurationAttribut.':'.(is_array($configurationValue)?implode(',', $configurationValue):$configurationValue);
80
+                            $configurationList[] = $configurationAttribut.':'.(is_array($configurationValue) ?implode(',', $configurationValue) : $configurationValue);
81 81
                         }
82 82
                         $temp[] = implode("\n", $configurationList);
83 83
                     }
Please login to merge, or discard this patch.
src/Commands/AddNotificationByHost.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
             $attributes = config('server-monitor-plugin-notification-by-host.notifications.channels.'.$channel);
56 56
             foreach ($attributes as $attribute => $type) {
57 57
                 config('server-monitor.notifications.channels.'.$channel);
58
-                $result = $this->ask("For channel `$channel` attribute `$attribute`?".($type == 'array'?" (values separate by ,)":""), false);
59
-                if($result) {
60
-                    if($type == 'array') {
58
+                $result = $this->ask("For channel `$channel` attribute `$attribute`?".($type == 'array' ? " (values separate by ,)" : ""), false);
59
+                if ($result) {
60
+                    if ($type == 'array') {
61 61
                         $configure[$channel][$attribute] = explode(',', $result);
62 62
                     }
63 63
                     else {
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
                 : $this->choice('Which host?', $hostList);
80 80
 
81 81
             $host = $this->determineHostModelClass()::where('name', $hostName)->first();
82
-            if(!$host) {
82
+            if (!$host) {
83 83
                 $this->warn("This host `{$hostName}` doesn't exist");
84 84
             }
85
-        } while(!$host);
85
+        } while (!$host);
86 86
 
87 87
         $this->info("Host: {$host->name}");
88 88
         return $host;
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
         }
98 98
 
99 99
         $notificationsParameters = [];
100
-        foreach(config('server-monitor.notifications.notifications') as $class => $notification) {
100
+        foreach (config('server-monitor.notifications.notifications') as $class => $notification) {
101 101
             $this->line("Notification for ".$class);
102 102
 
103 103
             $channels = $this->choice('Which channel? (values separate by ,)', $notifications, 0, null, true);
104
-            if($channels[0] != 'No channel') {
104
+            if ($channels[0] != 'No channel') {
105 105
                 $notificationsParameters[$class]['channels'] = $channels;
106 106
             }
107 107
         }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     }
110 110
 
111 111
     private function configuration($host, $notificationsParameters) {
112
-        if(!$notificationsParameters) {
112
+        if (!$notificationsParameters) {
113 113
             $this->warn("The host {$host->name} has no notification configure !");
114 114
         }
115 115
         else {
Please login to merge, or discard this patch.
src/ServerMonitorPluginNotificationByHostServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     {
14 14
         if ($this->app->runningInConsole()) {
15 15
             $this->publishes([
16
-                __DIR__ . '/../config/server-monitor-plugin-notification-by-host.php' => config_path('server-monitor-plugin-notification-by-host.php'),
16
+                __DIR__.'/../config/server-monitor-plugin-notification-by-host.php' => config_path('server-monitor-plugin-notification-by-host.php'),
17 17
             ], 'config');
18 18
 
19 19
         }
Please login to merge, or discard this patch.