BasicFixes::flush()   A
last analyzed

Complexity

Conditions 5
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
cc 5
eloc 2
c 3
b 1
f 0
nc 2
nop 0
dl 0
loc 4
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') && (DB::get_schema()->hasTable('Member') && ! Environment::getEnv('SS_EK_SPREEK_AFRIKAANS'))) {
13
            DB::query('UPDATE Member SET Member.Locale = \'en_US\' WHERE Member.Locale = \'af_ZA\'');
14
        }
15
    }
16
17
    protected static function table_exists($tableName)
18
    {
19
        $tables = DB::table_list();
20
        return in_array($tableName, $tables);
21
    }
22
}
23