Pchp.Library.Streams.TextElement.FromValue C# (CSharp) Method

FromValue() public static method

public static FromValue ( Context ctx, PhpValue value ) : TextElement
ctx Pchp.Core.Context
value Pchp.Core.PhpValue
return TextElement
        public static TextElement FromValue(Context ctx, PhpValue value)
        {
            switch (value.TypeCode)
            {
                case PhpTypeCode.Object:
                    if (value.Object is byte[])
                    {
                        return new TextElement((byte[])value.Object);
                    }
                    goto default;

                case PhpTypeCode.WritableString:
                    return new TextElement(value.WritableString, ctx.StringEncoding);

                default:
                    return new TextElement(value.ToStringOrThrow(ctx));
            }
        }
    }