protected function compile($config, $prefix = '') {
        $code = '';
        foreach ($config as $key => $value) {
            if (is_array($value)) {
                $code .= $this->compile($value, $prefix . $key . $this->sectionSeparator);
            } else {
                $fullName = $prefix . $key;
                if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $fullName)) {
                    throw new InvalidArgumentException(__CLASS__ . ": Cannot compile translation key " . $fullName . " because it is not a valid PHP identifier.");
                }
                $code .= 'const ' . $fullName . ' = \'' . str_replace('\'', '\\\'', $value) . "';\n";
            }
        }
        return $code;
    }
protected function compile($config, $prefix = '') {
        $code = '';
        foreach ($config as $key => $value) {
            if (is_array($value)) {
                $code .= $this->compile($value, $prefix . $key . $this->sectionSeparator);
            } else {
                $fullName = $prefix . $key;
                if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $fullName)) {
                    throw new InvalidArgumentException(__CLASS__ . ": Cannot compile translation key " . $fullName . " because it is not a valid PHP identifier.");
                }
                $code .= 'const ' . $fullName . ' = \'' . str_replace('\'', '\\\'', $value) . "';\n";
            }
        }
        return $code;
    }
protected function compile ( $ config , $ prefix = '' ) { $ code = '' ; foreach ( $ config as $ key => $ value ) { if ( is_array ( $ value ) ) { $ code .= $ this -> compile ( $ value , $ prefix . $ key . $ this -> sectionSeparator ) ; } else { $ fullName = $ prefix . $ key ; if ( ! preg_match ( '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/' , $ fullName ) ) { throw new InvalidArgumentException ( __CLASS__ . ": Cannot compile translation key " . $ fullName . " because it is not a valid PHP identifier." ) ; } $ code .= 'const ' . $ fullName . ' = \'' . str_replace ( '\'' , '\\\'' , $ value ) . "';\n" ; } } return $ code ; }
Recursively compile an associative array to PHP code.
Recursively compile an associative array to PHP code .