Completed
Pull Request — master (#40)
by
unknown
02:11
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
    /**
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
}