Pchp.Library.Arrays.StringKeysToLower C# (CSharp) Method

StringKeysToLower() static private method

Converts string keys in PhpArray to lower case.
Integer keys as well as all values remain unchanged.
static private StringKeysToLower ( PhpArray array ) : PhpArray
array Pchp.Core.PhpArray The to be converted.
return Pchp.Core.PhpArray
        internal static PhpArray StringKeysToLower(PhpArray/*!*/ array)
        {
            if (array == null)
            {
                //PhpException.ArgumentNull("array");
                //return null;
                throw new ArgumentNullException();
            }

            PhpArray result = new PhpArray();

            var textInfo = System.Globalization.CultureInfo.CurrentCulture.TextInfo; // cache current culture to avoid repetitious CurrentCulture.get

            using (var iterator = array.GetFastEnumerator())
                while (iterator.MoveNext())
                {
                    var entry = iterator.Current;
                    if (entry.Key.IsString)
                    {
                        result[textInfo.ToLower(entry.Key.String)] = entry.Value;
                    }
                    else
                        result[entry.Key] = entry.Value;
                }
            return result;
        }