Passed
Push — main ( f11f1e...f1cf78 )
by mohsen
06:10 queued 02:22
created
src/Traits/MessageCreatorTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
     public function hardDiskMessage($hardDiskUsage)
35 35
     {
36 36
         return "hard disk free space ===> $hardDiskUsage Byte (" .
37
-            number_format($hardDiskUsage / 1024 / 1024 / 1024, 2, '.', '') .  ' GB)';
37
+            number_format($hardDiskUsage / 1024 / 1024 / 1024, 2, '.', '') . ' GB)';
38 38
     }
39 39
 
40 40
     /**
Please login to merge, or discard this patch.
src/Commands/ListenCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -64,19 +64,19 @@
 block discarded – undo
64 64
             );
65 65
         }
66 66
 
67
-        if ($resources->contains('memory')  || $resourcesIsEmpty) {
67
+        if ($resources->contains('memory') || $resourcesIsEmpty) {
68 68
             $this->info(
69 69
                 $this->memoryMessage($this->memory->check())
70 70
             );
71 71
         }
72 72
 
73
-        if ($resources->contains('network')  || $resourcesIsEmpty) {
73
+        if ($resources->contains('network') || $resourcesIsEmpty) {
74 74
             $this->info(
75 75
                 $this->networkMessage($this->network->check())
76 76
             );
77 77
         }
78 78
 
79
-        if ($resources->contains('web-server')  || $resourcesIsEmpty) {
79
+        if ($resources->contains('web-server') || $resourcesIsEmpty) {
80 80
             $this->info(
81 81
                 $this->webServerMessage($this->webServer->check())
82 82
             );
Please login to merge, or discard this patch.
src/LogRecord/Drivers/FileDriver.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@
 block discarded – undo
30 30
         if ($log != '') {
31 31
             $log = $this->timeMessage() . "\n" . $log;
32 32
 
33
-            if ($this->storage->exists($file))
34
-                $log = $this->storage->get($file) . "\n \n" . $log;
33
+            if ($this->storage->exists($file)) {
34
+                            $log = $this->storage->get($file) . "\n \n" . $log;
35
+            }
35 36
 
36 37
             $this->storage->put($file, $log);
37 38
         }
Please login to merge, or discard this patch.
src/Services/WebServer.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,10 +8,11 @@
 block discarded – undo
8 8
 
9 9
     public function check(): string
10 10
     {
11
-        if (config('stethoscope.web_server_name') == 'nginx')
12
-            $this->checkNginx();
13
-        elseif (config('stethoscope.web_server_name') == 'apache')
14
-            $this->checkApache();
11
+        if (config('stethoscope.web_server_name') == 'nginx') {
12
+                    $this->checkNginx();
13
+        } elseif (config('stethoscope.web_server_name') == 'apache') {
14
+                    $this->checkApache();
15
+        }
15 16
 
16 17
         return $this->webServerStatuses;
17 18
     }
Please login to merge, or discard this patch.
src/Commands/MonitorCommand.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function handle()
48 48
     {
49
-        $resourceReports = [];
49
+        $resourceReports = [ ];
50 50
 
51 51
         $cpuUsage = $this->cpu->check();
52 52
         $memoryUsage = $this->memory->check();
@@ -55,19 +55,19 @@  discard block
 block discarded – undo
55 55
         $webServerStatuses = $this->webServer->check();
56 56
 
57 57
         if (config('stethoscope.monitorable_resources.cpu') && $cpuUsage > config(('stethoscope.thresholds.cpu')))
58
-            $resourceReports['cpu'] = $cpuUsage;
58
+            $resourceReports[ 'cpu' ] = $cpuUsage;
59 59
 
60 60
         if ($memoryUsage > config(('stethoscope.thresholds.memory')) && config('stethoscope.monitorable_resources.memory'))
61
-            $resourceReports['memory'] = $memoryUsage;
61
+            $resourceReports[ 'memory' ] = $memoryUsage;
62 62
 
63 63
         if ($networkStatus == 'false' && config('stethoscope.monitorable_resources.network'))
64
-            $resourceReports['network'] = $networkStatus;
64
+            $resourceReports[ 'network' ] = $networkStatus;
65 65
 
66 66
         if ($hardDiskFreeSpace < config(('stethoscope.thresholds.hard_disk')) && config('stethoscope.monitorable_resources.hard_disk'))
67
-            $resourceReports['hardDisk'] = $hardDiskFreeSpace;
67
+            $resourceReports[ 'hardDisk' ] = $hardDiskFreeSpace;
68 68
 
69 69
         if ($webServerStatuses != 'active' && config('stethoscope.monitorable_resources.web_server'))
70
-            $resourceReports['webServer'] = $webServerStatuses;
70
+            $resourceReports[ 'webServer' ] = $webServerStatuses;
71 71
 
72 72
         Record::record($resourceReports);
73 73
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -54,24 +54,30 @@
 block discarded – undo
54 54
         $hardDiskFreeSpace = $this->hardDisk->check();
55 55
         $webServerStatuses = $this->webServer->check();
56 56
 
57
-        if (config('stethoscope.monitorable_resources.cpu') && $cpuUsage > config(('stethoscope.thresholds.cpu')))
58
-            $resourceReports['cpu'] = $cpuUsage;
57
+        if (config('stethoscope.monitorable_resources.cpu') && $cpuUsage > config(('stethoscope.thresholds.cpu'))) {
58
+                    $resourceReports['cpu'] = $cpuUsage;
59
+        }
59 60
 
60
-        if ($memoryUsage > config(('stethoscope.thresholds.memory')) && config('stethoscope.monitorable_resources.memory'))
61
-            $resourceReports['memory'] = $memoryUsage;
61
+        if ($memoryUsage > config(('stethoscope.thresholds.memory')) && config('stethoscope.monitorable_resources.memory')) {
62
+                    $resourceReports['memory'] = $memoryUsage;
63
+        }
62 64
 
63
-        if ($networkStatus == 'false' && config('stethoscope.monitorable_resources.network'))
64
-            $resourceReports['network'] = $networkStatus;
65
+        if ($networkStatus == 'false' && config('stethoscope.monitorable_resources.network')) {
66
+                    $resourceReports['network'] = $networkStatus;
67
+        }
65 68
 
66
-        if ($hardDiskFreeSpace < config(('stethoscope.thresholds.hard_disk')) && config('stethoscope.monitorable_resources.hard_disk'))
67
-            $resourceReports['hardDisk'] = $hardDiskFreeSpace;
69
+        if ($hardDiskFreeSpace < config(('stethoscope.thresholds.hard_disk')) && config('stethoscope.monitorable_resources.hard_disk')) {
70
+                    $resourceReports['hardDisk'] = $hardDiskFreeSpace;
71
+        }
68 72
 
69
-        if ($webServerStatuses != 'active' && config('stethoscope.monitorable_resources.web_server'))
70
-            $resourceReports['webServer'] = $webServerStatuses;
73
+        if ($webServerStatuses != 'active' && config('stethoscope.monitorable_resources.web_server')) {
74
+                    $resourceReports['webServer'] = $webServerStatuses;
75
+        }
71 76
 
72 77
         Record::record($resourceReports);
73 78
 
74
-        if (!empty($resourceReports))
75
-            TroubleOccurred::dispatch($resourceReports);
79
+        if (!empty($resourceReports)) {
80
+                    TroubleOccurred::dispatch($resourceReports);
81
+        }
76 82
     }
77 83
 }
Please login to merge, or discard this patch.
src/Models/ResourceLog.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 {
11 11
     use HasFactory;
12 12
 
13
-    protected $guarded = [];
13
+    protected $guarded = [ ];
14 14
 
15 15
     protected static function newFactory()
16 16
     {
Please login to merge, or discard this patch.
database/migrations/2022_12_03_070906_create_resource_logs_table.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
     public function up()
15 15
     {
16
-        Schema::create('resource_logs', function (Blueprint $table) {
16
+        Schema::create('resource_logs', function(Blueprint $table) {
17 17
             $table->id();
18 18
             $table->string('resource');
19 19
             $table->string('log');
Please login to merge, or discard this patch.
src/Http/Controllers/MonitorController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
             ->select(DB::raw('date(created_at) as date'), 'resource')
32 32
             ->get();
33 33
 
34
-        $labels = [];
34
+        $labels = [ ];
35 35
         foreach (CarbonPeriod::create($from, $to) as $date) {
36 36
             array_push($labels, $date->format('Y-m-d'));
37 37
         }
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 
51 51
     protected function resourceLogCount($resource, $labels, $resourceLogs)
52 52
     {
53
-        $logCount = [];
53
+        $logCount = [ ];
54 54
         foreach ($labels as $label) {
55
-            $resourceCount = $resourceLogs->countBy(function ($resourceLogs) use ($resource, $label) {
56
-                return $resourceLogs['resource'] == $resource && $resourceLogs['date'] == $label;
55
+            $resourceCount = $resourceLogs->countBy(function($resourceLogs) use ($resource, $label) {
56
+                return $resourceLogs[ 'resource' ] == $resource && $resourceLogs[ 'date' ] == $label;
57 57
             });
58
-            array_push($logCount, count($resourceCount) > 1 ? $resourceCount[1] : 0);
58
+            array_push($logCount, count($resourceCount) > 1 ? $resourceCount[ 1 ] : 0);
59 59
         }
60 60
         return $logCount;
61 61
     }
Please login to merge, or discard this patch.
database/factories/ResourceLogFactory.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@
 block discarded – undo
11 11
 
12 12
     public function definition()
13 13
     {
14
-        $resources = ['cpu', 'memory', 'hardDisk', 'network', 'webServer'];
14
+        $resources = [ 'cpu', 'memory', 'hardDisk', 'network', 'webServer' ];
15 15
 
16 16
         return [
17
-            'resource' => $resources[random_int(0, 4)],
17
+            'resource' => $resources[ random_int(0, 4) ],
18 18
             'log' => $this->faker->text()
19 19
         ];
20 20
     }
Please login to merge, or discard this patch.