src/Mordilion/Configurable/Configuration/Writer/Ini.php
private function encodeKeyValuePair(string $key, $value, bool $enclose = false): string
    {
        $keyPrefix = ($enclose ? '[' : '');
        $keySuffix = ($enclose ? ']' : '');
        $trueValues = array(true, 'true', 'yes', 'on');
        $falseValues = array(false, 'false', 'no', 'off');

        if (is_array($value)) {
            $result = '';

            foreach ($value as $k => $v) {
                $result .= $keyPrefix . $key . $keySuffix;
                $result .= $this->encodeKeyValuePair($k, $v, true);
            }

            return $result;
        } 

        if (is_numeric($value)) {
            return $keyPrefix . $key . $keySuffix . ' = ' . $value . PHP_EOL;
        } 

        if (is_bool($value)) {
            return $keyPrefix . $key . $keySuffix . ' = ' . ($value ? 'true' : 'false') . PHP_EOL;
        }

        return $keyPrefix . $key . $keySuffix . ' = "' . $value . '"' . PHP_EOL;
    }
private function encodeKeyValuePair(string $key, $value, bool $enclose = false): string
    {
        $keyPrefix = ($enclose ? '[' : '');
        $keySuffix = ($enclose ? ']' : '');
        $trueValues = array(true, 'true', 'yes', 'on');
        $falseValues = array(false, 'false', 'no', 'off');

        if (is_array($value)) {
            $result = '';

            foreach ($value as $k => $v) {
                $result .= $keyPrefix . $key . $keySuffix;
                $result .= $this->encodeKeyValuePair($k, $v, true);
            }

            return $result;
        } 

        if (is_numeric($value)) {
            return $keyPrefix . $key . $keySuffix . ' = ' . $value . PHP_EOL;
        } 

        if (is_bool($value)) {
            return $keyPrefix . $key . $keySuffix . ' = ' . ($value ? 'true' : 'false') . PHP_EOL;
        }

        return $keyPrefix . $key . $keySuffix . ' = "' . $value . '"' . PHP_EOL;
    }
private function encodeKeyValuePair ( string $ key , $ value , bool $ enclose = false ) : string { $ keyPrefix = ( $ enclose ? '[' : '' ) ; $ keySuffix = ( $ enclose ? ']' : '' ) ; $ trueValues = array ( true , 'true' , 'yes' , 'on' ) ; $ falseValues = array ( false , 'false' , 'no' , 'off' ) ; if ( is_array ( $ value ) ) { $ result = '' ; foreach ( $ value as $ k => $ v ) { $ result .= $ keyPrefix . $ key . $ keySuffix ; $ result .= $ this -> encodeKeyValuePair ( $ k , $ v , true ) ; } return $ result ; } if ( is_numeric ( $ value ) ) { return $ keyPrefix . $ key . $ keySuffix . ' = ' . $ value . PHP_EOL ; } if ( is_bool ( $ value ) ) { return $ keyPrefix . $ key . $ keySuffix . ' = ' . ( $ value ? 'true' : 'false' ) . PHP_EOL ; } return $ keyPrefix . $ key . $ keySuffix . ' = "' . $ value . '"' . PHP_EOL ; }
Encodes the provided $key and $value into a assignment string.

@param string $key
@param array|string $value
@param boolean $enclose

@return string
Encodes the provided $key and $value into a assignment string .