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

GrammarFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 12 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
	 * @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
}