public static IPhpArray EnsureItemArray(IPhpArray array, PhpValue index) { if (Convert.TryToIntStringKey(index, out IntStringKey key)) { return(array.EnsureItemArray(key)); } else { throw new ArgumentException(); } }
/// <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 } }
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)); } }
/// <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); } }