Test Failed
Pull Request — master (#85)
by Keoghan
06:33
created

ChooseMechanic::forOS()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 11
ccs 0
cts 6
cp 0
rs 10
cc 4
nc 3
nop 1
crap 20
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
    public static function forOS($os = null)
21
    {
22
        $os = $os ?: PHP_OS;
23
24
        foreach (static::MECHANICS as $key => $class) {
25
            if (stristr($os, $key)) {
26
                return app()->make($class);
27
            }
28
        }
29
30
        return app()->make(Untrained::class);
31
    }
32
}
33