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

BasicFixes::flush()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
cc 5
eloc 3
c 3
b 1
f 0
nc 3
nop 0
dl 0
loc 5
rs 9.6111
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