WebServer::checkApache()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
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