Completed
Push — master ( c2ca21...521c0e )
by Freek
11s
created

HostRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A determineHostModel() 0 10 2
1
<?php
2
3
namespace Spatie\ServerMonitor;
4
5
use Spatie\ServerMonitor\Models\Host;
6
use Spatie\ServerMonitor\Exceptions\InvalidConfiguration;
7
8
class HostRepository
9
{
10
    /**
11
     * Determine the host model class name.
12
     *
13
     * @return string
14
     *
15
     * @throws \Spatie\ServerMonitor\Exceptions\InvalidConfiguration
16
     */
17
    public static function determineHostModel(): string
18
    {
19
        $hostModel = config('server-monitor.host_model') ?? Host::class;
20
21
        if (! is_a($hostModel, Host::class, true)) {
22
            throw InvalidConfiguration::modelIsNotValid($hostModel);
23
        }
24
25
        return $hostModel;
26
    }
27
}
28