Code Duplication    Length = 37-37 lines in 2 locations

Alpha/Model/ActiveRecordProviderMySQL.php 1 location

@@ 2009-2045 (lines=37) @@
2006
        $indexNames = $this->getIndexes();
2007
2008
        // process unique keys
2009
        foreach ($this->BO->getUniqueAttributes() as $prop) {
2010
            // check for composite indexes
2011
            if (mb_strpos($prop, '+')) {
2012
                $attributes = explode('+', $prop);
2013
2014
                $index_exists = false;
2015
                foreach ($indexNames as $index) {
2016
                    if ($attributes[0].'_'.$attributes[1].'_unq_idx' == $index) {
2017
                        $index_exists = true;
2018
                    }
2019
                    if (count($attributes) == 3) {
2020
                        if ($attributes[0].'_'.$attributes[1].'_'.$attributes[2].'_unq_idx' == $index) {
2021
                            $index_exists = true;
2022
                        }
2023
                    }
2024
                }
2025
2026
                if (!$index_exists) {
2027
                    if (count($attributes) == 3) {
2028
                        $this->BO->createUniqueIndex($attributes[0], $attributes[1], $attributes[2]);
2029
                    } else {
2030
                        $this->BO->createUniqueIndex($attributes[0], $attributes[1]);
2031
                    }
2032
                }
2033
            } else {
2034
                $index_exists = false;
2035
                foreach ($indexNames as $index) {
2036
                    if ($prop.'_unq_idx' == $index) {
2037
                        $index_exists = true;
2038
                    }
2039
                }
2040
2041
                if (!$index_exists) {
2042
                    $this->createUniqueIndex($prop);
2043
                }
2044
            }
2045
        }
2046
2047
        // process foreign-key indexes
2048
        // get the class attributes

Alpha/Model/ActiveRecordProviderSQLite.php 1 location

@@ 2039-2075 (lines=37) @@
2036
        $indexNames = $this->BO->getIndexes();
2037
2038
        // process unique keys
2039
        foreach ($this->BO->getUniqueAttributes() as $prop) {
2040
            // check for composite indexes
2041
            if (mb_strpos($prop, '+')) {
2042
                $attributes = explode('+', $prop);
2043
2044
                $index_exists = false;
2045
                foreach ($indexNames as $index) {
2046
                    if ($attributes[0].'_'.$attributes[1].'_unq_idx' == $index) {
2047
                        $index_exists = true;
2048
                    }
2049
                    if (count($attributes) == 3) {
2050
                        if ($attributes[0].'_'.$attributes[1].'_'.$attributes[2].'_unq_idx' == $index) {
2051
                            $index_exists = true;
2052
                        }
2053
                    }
2054
                }
2055
2056
                if (!$index_exists) {
2057
                    if (count($attributes) == 3) {
2058
                        $this->BO->createUniqueIndex($attributes[0], $attributes[1], $attributes[2]);
2059
                    } else {
2060
                        $this->BO->createUniqueIndex($attributes[0], $attributes[1]);
2061
                    }
2062
                }
2063
            } else {
2064
                $index_exists = false;
2065
                foreach ($indexNames as $index) {
2066
                    if ($prop.'_unq_idx' == $index) {
2067
                        $index_exists = true;
2068
                    }
2069
                }
2070
2071
                if (!$index_exists) {
2072
                    $this->createUniqueIndex($prop);
2073
                }
2074
            }
2075
        }
2076
2077
        self::$logger->debug('<<checkIndexes');
2078
    }