Completed
Pull Request — master (#40)
by
unknown
02:11
created

HostRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 21
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
    /**
12
     * Determine the host model class name.
13
     *
14
     * @return string
15
     *
16
     * @throws \Spatie\ServerMonitor\Exceptions\InvalidConfiguration
17
     */
18
    public static function determineHostModel(): string
19
    {
20
        $hostModel = config('server-monitor.host_model') ?? Host::class;
21
22
        if (! is_a($hostModel, Host::class, true)) {
23
            throw InvalidConfiguration::modelIsNotValid($hostModel);
24
        }
25
26
        return $hostModel;
27
    }
28
}