ChooseMechanic   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 10
dl 0
loc 26
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A forOS() 0 11 4
1
<?php
2
3
namespace App\Support\Mechanics;
4
5
class ChooseMechanic
6
{
7
    const MECHANICS = [
8
        'DAR'   => MacOs::class,
9
        'WIN'   => Windows::class,
10
        'LINUX' => Linux::class,
11
    ];
12
13
    /**
14
     * Get the mechanic for the host operating system.
15
     *
16
     * @param string|null $os
17
     *
18
     * @return Mechanic
19
     */
20 210
    public static function forOS($os = null)
21
    {
22 210
        $os = $os ?: PHP_OS;
23
24 210
        foreach (static::MECHANICS as $key => $class) {
25 210
            if (stristr($os, $key)) {
26 210
                return app()->make($class);
27
            }
28
        }
29
30 1
        return app()->make(Untrained::class);
31
    }
32
}
33