src/Translate.php
private function flatten(?array $arr, string $group, ?string $lang = null): ?array
    {
        if ($arr === null) {
            return null;
        }

        if (!isset($this->arrayGroups[$group])) {
            throw new \OutOfBoundsException("Invalid group: $group");
        }

        if ($lang === null) {
            $lang = $this->lang;
        }

        if (!isset($this->arrayGroups[$group][$lang])) {
            throw new \OutOfBoundsException("Invalid language: $lang");
        }
        
        $keep = $this->arrayGroups[$group][$lang];
        
        if (!array_key_exists($keep, $arr)) {
            throw new \OutOfBoundsException("Invalid array index: $keep");
        }

        $arr[$group] = $arr[$keep];
        foreach ($this->arrayGroups[$group] as $g) {
            unset($arr[$g]);
        }
        
        return $arr;
    }
private function flatten(?array $arr, string $group, ?string $lang = null): ?array
    {
        if ($arr === null) {
            return null;
        }

        if (!isset($this->arrayGroups[$group])) {
            throw new \OutOfBoundsException("Invalid group: $group");
        }

        if ($lang === null) {
            $lang = $this->lang;
        }

        if (!isset($this->arrayGroups[$group][$lang])) {
            throw new \OutOfBoundsException("Invalid language: $lang");
        }
        
        $keep = $this->arrayGroups[$group][$lang];
        
        if (!array_key_exists($keep, $arr)) {
            throw new \OutOfBoundsException("Invalid array index: $keep");
        }

        $arr[$group] = $arr[$keep];
        foreach ($this->arrayGroups[$group] as $g) {
            unset($arr[$g]);
        }
        
        return $arr;
    }
private function flatten ( ? array $ arr , string $ group , ? string $ lang = null ) : ? array { if ( $ arr === null ) { return null ; } if ( ! isset ( $ this -> arrayGroups [ $ group ] ) ) { throw new \ OutOfBoundsException ( "Invalid group: $group" ) ; } if ( $ lang === null ) { $ lang = $ this -> lang ; } if ( ! isset ( $ this -> arrayGroups [ $ group ] [ $ lang ] ) ) { throw new \ OutOfBoundsException ( "Invalid language: $lang" ) ; } $ keep = $ this -> arrayGroups [ $ group ] [ $ lang ] ; if ( ! array_key_exists ( $ keep , $ arr ) ) { throw new \ OutOfBoundsException ( "Invalid array index: $keep" ) ; } $ arr [ $ group ] = $ arr [ $ keep ] ; foreach ( $ this -> arrayGroups [ $ group ] as $ g ) { unset ( $ arr [ $ g ] ) ; } return $ arr ; }
Flattens an array group
@param array $arr The array to localize
@param string $group The name of the group of fields to flatten
@param string $lang The output language. Default is default language.
@return array
@throws \OutOfBoundsException If the group does not exist or if the array values do not contain the key in a given language
Flattens an array group