Completed
Pull Request — master (#3)
by
unknown
08:58
created

GrammarFactory::make()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
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 12
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
	 * @param string $name
17
	 *
18
	 * @return \Illuminate\Database\Schema\Grammars\Grammar
19
	 */
20 27
	public static function make(string $name): Grammar {
21 27
		switch($name){
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) after SWITCH keyword; 0 found
Loading history...
22 27
			case 'mysql':
23 13
				return new MySqlGrammar();
24
				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...
25 14
			case 'postgresql':
26 1
			case 'pg_sql':
27 13
				return new PostgresGrammar();
28
				break;
29
		}
30
31 1
		throw new \InvalidArgumentException(\sprintf('%s is not a supported grammar.', $name));
32
	}
33
}