WebServer::check()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace MohsenAbrishami\Stethoscope\Services;
4
5
class WebServer implements ServiceInterface
6
{
7
    public $webServerStatuses = null;
8
9
    public function check(): string
10
    {
11
        if (config('stethoscope.web_server_name') == 'nginx') {
12
            $this->checkNginx();
13
        } elseif (config('stethoscope.web_server_name') == 'apache') {
14
            $this->checkApache();
15
        }
16
17
        return $this->webServerStatuses;
18
    }
19
20
    protected function checkNginx()
21
    {
22
        $this->webServerStatuses = exec('systemctl is-active nginx');
23
    }
24
25
    protected function checkApache()
26
    {
27
        $this->webServerStatuses = exec('systemctl is-active apache2.service');
28
    }
29
}
30