Component::version()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
crap 2
1
<?php
2
3
namespace BootPress\Bootstrap;
4
5
class Component
6
{
7 31
    public static function version($number)
8
    {
9 31
        $version = (int) substr($number, 0, 1);
10
        switch ($version) {
11 31
            case 3:
12 30
                return new Bootstrap3($number);
13
            break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
14 1
            default:
15 1
                throw new \Exception("Bootstrap version {$version} is not currently supported.");
16 1
        }
17
    }
18
}
19