Beispiel #1
0
            public PhpFunctionGroup(string @namespace, MethodGroup o)
            {
                var functions = o.Methods.Select(m => new PhpOperation(m));

                Class = PHP.Class(
                    name: Class.CreateName(@namespace, o.Name),
                    constructor: PHP.Constructor(
                        parameters: GroupConstructorParameters,
                        body: functions.SelectMany(f => f.ConstructorStatements)),
                    functions: functions.Select(f => f.Function),
                    properties: functions.Select(f => f.Property));

                Property = PHP.Property(Class.Name, "_" + o.Name + "_group");

                Create = PHP
                         .This
                         .Arrow(Property)
                         .Assign(PHP.New(Class.Name, ClientParameterRef))
                         .Statement();

                Function = PHP.Function(
                    name: $"get{o.Name}",
                    @return: Class,
                    body: PHP.Statements(PHP.Return(PHP.This.Arrow(Property))));
            }
Beispiel #2
0
            public PhpOperation(Method m)
            {
                var name = "_" + m.Name + "_operation";

                Property = PHP.Property(new ClassName(MicrosoftRestOperationInterface), name);

                var thisProperty = PHP.This.Arrow(Property);

                ConstructorStatements = OperationInfoInit(thisProperty, m);

                var parameters = m.Parameters
                                 .Where(p => !p.IsConstant &&
                                        !p.IsApiVersion() &&
                                        p.SerializedName != "subscriptionId");

                var call = PHP.Return(thisProperty.Call(
                                          CallFunction,
                                          PHP.CreateArray(parameters.Select(p => PHP.KeyValue(
                                                                                p.SerializedName,
                                                                                new ObjectName(p.SerializedName).Ref())))));

                Function = PHP.Function(
                    name: m.Name,
                    description: m.Description,
                    @return: m.ReturnType.Body == null ? null : SchemaObject.Create(m.ReturnType.Body).ToPhpType(),
                    parameters: parameters.Select(p => {
                    var phpType = SchemaObject.Create(p.ModelType).ToPhpType();
                    return(PHP.Parameter(
                               p.IsRequired ? phpType : new Nullable(phpType),
                               new ObjectName(p.SerializedName)));
                }),
                    body: PHP.Statements(call));
            }