Passed
Push — master ( 82e7cc...d5f949 )
by Nicolaas
04:17
created

BasicFixes::table_exists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
use SilverStripe\Core\Environment;
4
use SilverStripe\Core\Flushable;
5
use SilverStripe\ORM\DB;
6
use SilverStripe\Security\Security;
7
8
class BasicFixes implements Flushable
9
{
10
    public static function flush()
11
    {
12
        if(Security::database_is_ready() && self::table_exists('Member')) {
13
            if(DB::get_schema()->hasTable('Member') && ! Environment::getEnv('SS_EK_SPREEK_AFRIKAANS')) {
14
                DB::query('UPDATE Member SET Member.Locale = \'en_US\' WHERE Member.Locale = \'af_ZA\'');
15
            }
16
        }
17
    }
18
19
    protected static function table_exists($tableName)
20
    {
21
        $tables = DB::table_list();
22
        return in_array($tableName, $tables);
23
    }
24
}
25