GrammarFactory::make()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 9
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 13
ccs 8
cts 8
cp 1
crap 4
rs 9.9666
1
<?php
2
3
namespace LaravelSpatial\Schema\Grammars;
4
5
use Illuminate\Database\Schema\Grammars\Grammar;
6
7
/**
8
 * Class GrammarFactory
9
 *
10
 * @package LaravelSpatial\Schema\Grammars
11
 * @internal
12
 */
13
class GrammarFactory
14
{
15
16
    /**
17
     * @param string $name
18
     *
19
     * @return \Illuminate\Database\Schema\Grammars\Grammar
20
     */
21 27
    public static function make(string $name): Grammar
22
    {
23 27
        switch ($name) {
24 27
            case 'mysql':
25 13
                return new MySqlGrammar();
26
                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...
27 14
            case 'postgresql':
28 1
            case 'pg_sql':
29 13
                return new PostgresGrammar();
30
                break;
31
        }
32
33 1
        throw new \InvalidArgumentException(\sprintf('%s is not a supported grammar.', $name));
34
    }
35
}
36