Passed
Pull Request — master (#3)
by
unknown
04:05
created

GrammarFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 10
c 2
b 1
f 0
dl 0
loc 21
ccs 8
cts 8
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 13 4
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