Test Failed
Branch feature__set_up_scrutinizer (ea6624)
by Robin
06:04 queued 02:46
created

ChooseMechanic::forOS()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 5

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 16
ccs 9
cts 9
cp 1
rs 9.6111
c 0
b 0
f 0
cc 5
nc 4
nop 1
crap 5
1
<?php
2
3
namespace App\Support\Mechanics;
4
5
class ChooseMechanic
6
{
7
    /**
8
     * Get the mechanic for the host operating system.
9
     *
10
     * @param string|null $os
11
     * @return Mechanic
12
     */
13 50
    public static function forOS($os = null)
14
    {
15 50
        $os = $os ?: PHP_OS;
16
17
        switch (true) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stristr($os, 'WIN') of type string to the boolean true. If you are specifically checking for a non-empty string, consider using the more explicit !== '' instead.
Loading history...
Bug Best Practice introduced by
It seems like you are loosely comparing stristr($os, 'LINUX') of type string to the boolean true. If you are specifically checking for a non-empty string, consider using the more explicit !== '' instead.
Loading history...
Bug Best Practice introduced by
It seems like you are loosely comparing stristr($os, 'DAR') of type string to the boolean true. If you are specifically checking for a non-empty string, consider using the more explicit !== '' instead.
Loading history...
18 50
            case stristr($os, 'DAR'):
19 1
                return app(MacOs::class);
20
21 50
            case stristr($os, 'WIN'):
22 1
                return app(Windows::class);
23
24 50
            case stristr($os, 'LINUX'):
25 50
                return app(Linux::class);
26
27
            default :
28 1
                return app(Untrained::class);
29
        }
30
    }
31
}
32