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

HostRepository::determineHostModel()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
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