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

key() public static method

Retrieves a key being pointed by an array intrinsic enumerator.
public static key ( IPhpEnumerable array ) : PhpValue
array IPhpEnumerable The array which current key to return.
return Pchp.Core.PhpValue
        public static PhpValue key(IPhpEnumerable array)
        {
            if (array == null)
            {
                //PhpException.ReferenceNull("array");
                //return null;
                throw new ArgumentNullException();
            }

            if (array.IntrinsicEnumerator.AtEnd)
                return PhpValue.Null;

            // note, key can't be of type PhpReference, hence no dereferencing follows:
            return array.IntrinsicEnumerator.CurrentKey.GetValue();
        }