// Public Methods public bool TryGetPhpString(out string txt) { switch (kind) { case Kinds.StringConstant: if (PhpValues.TryGetPhpStringValue(phpValue, out txt)) { return(true); } throw new NotSupportedException(); case Kinds.Bool: txt = (bool)sourceValue ? "1" : ""; return(true); case Kinds.Int: case Kinds.OctalInt: txt = ((int)sourceValue).ToString(); return(true); case Kinds.Double: txt = phpValue; return(true); case Kinds.DefinedConst: txt = ""; return(false); case Kinds.Null: txt = ""; return(true); default: throw new NotSupportedException(); } }
public void AddFormat(string f, params object[] o) { var oo = o.Select(i => PhpValues.ToPhpCodeValue(i)).ToArray(); s.AppendFormat(f, oo); }
public void Add(object o) { s.Append(PhpValues.ToPhpCodeValue(o)); }
public static PhpCodeValue FromString(string txt) { return(new PhpCodeValue(PhpValues.PhpStringEmit(txt, true), txt, Kinds.StringConstant)); }
public static PhpCodeValue FromInt(int v, bool octal = false) { var txt = octal ? PhpValues.Dec2Oct(v) : v.ToString(); return(new PhpCodeValue(txt, v, octal ? Kinds.OctalInt : Kinds.Int)); }