Completed
Push — master ( 087a45...fbf294 )
by Antonio
02:27
created

MigrationHelper::resolveDbType()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
ccs 0
cts 15
cp 0
rs 8.8571
cc 6
eloc 12
nc 6
nop 1
crap 42
1
<?php
2
3
namespace Da\User\Helper;
4
5
use RuntimeException;
6
7
class MigrationHelper
8
{
9
    /**
10
     * @param string $driverName
11
     *
12
     * @return null|string
13
     */
14
    public static function resolveTableOptions($driverName)
15
    {
16
        switch ($driverName) {
17
            case 'mysql':
18
                return 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
19
            case 'pgsql':
20
            case 'dblib':
21
            case 'mssql':
22
            case 'sqlsrv':
23
                return null;
24
            default:
25
                throw new RuntimeException('Your database is not supported!');
26
        }
27
    }
28
29
    /**
30
     * @param $driverName
31
     *
32
     * @return string
33
     */
34
    public static function resolveDbType($driverName)
35
    {
36
        switch ($driverName) {
37
            case 'mysql':
38
                return $driverName;
39
            case 'pgsql':
40
                return $driverName;
41
            case 'dblib':
42
            case 'mssql':
43
            case 'sqlsrv':
44
                return 'sqlsrv';
45
            default:
46
                throw new RuntimeException('Your database is not supported!');
47
        }
48
    }
49
50
    /**
51
     * @param string $driverName
52
     *
53
     * @return bool
54
     */
55
    public static function isMicrosoftSQLServer($driverName)
56
    {
57
        return self::resolveDbType($driverName) == 'sqlsrv';
58
    }
59
}
60