Beispiel #1
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));
            }