Network::check()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 13
rs 10
1
<?php
2
3
namespace MohsenAbrishami\Stethoscope\Services;
4
5
use Exception;
6
use Illuminate\Support\Facades\Http;
7
8
class Network implements ServiceInterface
9
{
10
    public function check(): string
11
    {
12
        foreach(config('stethoscope.network_monitor_url') as $networkMonitorURL){
13
            try {
14
                Http::get($networkMonitorURL)->successful();
15
                $networkConnction = 'connected';
16
                break;
17
            } catch (Exception $e) {
18
                $networkConnction = 'disconnected';
19
            }
20
        }
21
22
        return $networkConnction;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $networkConnction seems to be defined by a foreach iteration on line 12. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
23
    }
24
}
25