ChooseMechanic::forOS()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 4
nc 3
nop 1
crap 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