public static function rules($type, $config = array())
        {
            $var = '_' . $type;

            if (!isset(static::${$var})) {
                return null;
            }

            if (empty($config)) {
                return static::${$var};
            }

            switch ($type) {
                case 'transliteration':
                    $_config = array();

                    foreach ($config as $key => $val) {
                        if ($key[0] != '/') {
                            $key = '/' . join('|', array_filter(preg_split('//u', $key))) . '/';
                        }

                        $_config[$key] = $val;
                    }
                    static::$_transliteration = array_merge(
                        $_config, static::$_transliteration, $_config
                   );
                break;
                case 'uninflected':
                    static::$_uninflected = array_merge(static::$_uninflected, (array) $config);
                    static::$_plural['regexUninflected'] = null;
                    static::$_singular['regexUninflected'] = null;

                    foreach ((array) $config as $word) {
                        unset(static::$_singularized[$word], static::$_pluralized[$word]);
                    }
                break;
                case 'singular':
                case 'plural':
                    if (isset(static::${$var}[key($config)])) {
                        foreach ($config as $rType => $set) {
                            static::${$var}[$rType] = array_merge($set, static::${$var}[$rType], $set);

                            if ($rType == 'irregular') {
                                $swap = ($type == 'singular' ? '_plural' : '_singular');
                                static::${$swap}[$rType] = array_flip(static::${$var}[$rType]);
                            }
                        }
                    } else {
                        static::${$var}['rules'] = array_merge(
                            $config, static::${$var}['rules'], $config
                       );
                    }
                break;
            }
        }
public static function rules($type, $config = array())
        {
            $var = '_' . $type;

            if (!isset(static::${$var})) {
                return null;
            }

            if (empty($config)) {
                return static::${$var};
            }

            switch ($type) {
                case 'transliteration':
                    $_config = array();

                    foreach ($config as $key => $val) {
                        if ($key[0] != '/') {
                            $key = '/' . join('|', array_filter(preg_split('//u', $key))) . '/';
                        }

                        $_config[$key] = $val;
                    }
                    static::$_transliteration = array_merge(
                        $_config, static::$_transliteration, $_config
                   );
                break;
                case 'uninflected':
                    static::$_uninflected = array_merge(static::$_uninflected, (array) $config);
                    static::$_plural['regexUninflected'] = null;
                    static::$_singular['regexUninflected'] = null;

                    foreach ((array) $config as $word) {
                        unset(static::$_singularized[$word], static::$_pluralized[$word]);
                    }
                break;
                case 'singular':
                case 'plural':
                    if (isset(static::${$var}[key($config)])) {
                        foreach ($config as $rType => $set) {
                            static::${$var}[$rType] = array_merge($set, static::${$var}[$rType], $set);

                            if ($rType == 'irregular') {
                                $swap = ($type == 'singular' ? '_plural' : '_singular');
                                static::${$swap}[$rType] = array_flip(static::${$var}[$rType]);
                            }
                        }
                    } else {
                        static::${$var}['rules'] = array_merge(
                            $config, static::${$var}['rules'], $config
                       );
                    }
                break;
            }
        }
public static function rules ( $ type , $ config = array ( ) ) { $ var = '_' . $ type ; if ( ! isset ( static :: $ { $ var } ) ) { return null ; } if ( empty ( $ config ) ) { return static :: $ { $ var } ; } switch ( $ type ) { case 'transliteration' : $ _config = array ( ) ; foreach ( $ config as $ key => $ val ) { if ( $ key [ 0 ] != '/' ) { $ key = '/' . join ( '|' , array_filter ( preg_split ( '//u' , $ key ) ) ) . '/' ; } $ _config [ $ key ] = $ val ; } static :: $ _transliteration = array_merge ( $ _config , static :: $ _transliteration , $ _config ) ; break ; case 'uninflected' : static :: $ _uninflected = array_merge ( static :: $ _uninflected , ( array ) $ config ) ; static :: $ _plural [ 'regexUninflected' ] = null ; static :: $ _singular [ 'regexUninflected' ] = null ; foreach ( ( array ) $ config as $ word ) { unset ( static :: $ _singularized [ $ word ] , static :: $ _pluralized [ $ word ] ) ; } break ; case 'singular' : case 'plural' : if ( isset ( static :: $ { $ var } [ key ( $ config ) ] ) ) { foreach ( $ config as $ rType => $ set ) { static :: $ { $ var } [ $ rType ] = array_merge ( $ set , static :: $ { $ var } [ $ rType ] , $ set ) ; if ( $ rType == 'irregular' ) { $ swap = ( $ type == 'singular' ? '_plural' : '_singular' ) ; static :: $ { $ swap } [ $ rType ] = array_flip ( static :: $ { $ var } [ $ rType ] ) ; } } } else { static :: $ { $ var } [ 'rules' ] = array_merge ( $ config , static :: $ { $ var } [ 'rules' ] , $ config ) ; } break ; } }
Gets or adds inflection and transliteration rules.

@param string $type Either `'transliteration'`, `'uninflected'`, `'singular'` or `'plural'`.
@param array $config
@return mixed If `$config` is empty, returns the rules list specified
by `$type`, otherwise returns `null`.
Gets or adds inflection and transliteration rules .