WebServer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 9
c 5
b 0
f 0
dl 0
loc 23
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A checkNginx() 0 3 1
A checkApache() 0 3 1
A check() 0 9 3
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