TryToIntStringKey() public static method

Tries conversion to an array key.
public static TryToIntStringKey ( PhpValue value, IntStringKey &key ) : bool
value PhpValue
key IntStringKey
return bool
Ejemplo n.º 1
0
 public static IPhpArray EnsureItemArray(IPhpArray array, PhpValue index)
 {
     if (Convert.TryToIntStringKey(index, out IntStringKey key))
     {
         return(array.EnsureItemArray(key));
     }
     else
     {
         throw new ArgumentException();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Implements <c>[]</c> operator on <see cref="string"/>.
 /// </summary>
 public static string GetItemValue(string value, PhpValue index, bool quiet)
 {
     if (Convert.TryToIntStringKey(index, out IntStringKey key))
     {
         return(GetItemValue(value, key));
     }
     else
     {
         return(quiet
             ? (string)null
             : throw new ArgumentException());    // string.Empty + warning
     }
 }
Ejemplo n.º 3
0
        public static PhpAlias EnsureItemAlias(IPhpArray array, PhpValue index, bool quiet)
        {
            if (Convert.TryToIntStringKey(index, out IntStringKey key))
            {
                return(array.EnsureItemAlias(key));
            }
            else
            {
                if (!quiet)
                {
                    throw new ArgumentException();
                }

                return(new PhpAlias(PhpValue.Void));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Implements <c>[]</c> operator on <see cref="string"/>.
        /// </summary>
        public static string GetItemValue(string value, PhpValue index, bool quiet)
        {
            if (Convert.TryToIntStringKey(index, out IntStringKey key))
            {
                return(GetItemValue(value, key));
            }
            else
            {
                if (!quiet)
                {
                    throw new ArgumentException();
                }

                return(string.Empty);
            }
        }