<?php

namespace {{package}};

use Articus\PathHandler\Operation;
use Articus\PathHandler\Annotation as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;

{{#operations}}
/**
{{#description}}
 * {{&description}}
{{/description}}
 * @PHA\Route(pattern="{{pathPattern}}")
 */
class {{classname}} implements {{interfacesToImplement}}
{
{{#operation}}
    /**
{{#summary}}
     * {{summary}}
{{/summary}}
{{#description}}
     * {{description}}
{{/description}}
{{#vendorExtensions}}
{{#internal.ze-ph.hasQueryData}}
     * @PHA\Attribute(name=PHAttribute\Transfer::class, options={
     *     "type":{{internal.ze-ph.queryDataType}}::class,
     *     "objectAttr":"queryData",
     *     "source": PHAttribute\Transfer::SOURCE_GET
     * })
{{/internal.ze-ph.hasQueryData}}
{{/vendorExtensions}}
{{#bodyParam}}
{{#consumes}}
     * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
     * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="{{{mediaType}}}")
{{/consumes}}
{{^isPrimitiveType}}
{{#isContainer}}
     * TODO check if attribute is valid and can handle your container type
{{/isContainer}}
     * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":{{dataType}}::class,"objectAttr":"bodyData"})
{{/isPrimitiveType}}
{{/bodyParam}}
{{#produces}}
     * TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
     * @PHA\Producer(name=PHProducer\Transfer::class, mediaType="{{{mediaType}}}")
{{/produces}}
     * @param ServerRequestInterface $request
     *
     * @throws PHException\HttpCode 500 if the method is not implemented
{{#returnType}}
     *
     * @return {{returnType}}
{{/returnType}}
     */
    public function {{httpMethod}}(ServerRequestInterface $request)
    {
        //TODO implement method
{{#vendorExtensions}}
{{#internal.ze-ph.hasQueryData}}
        /** @var {{internal.ze-ph.queryDataType}} $queryData */
        $queryData = $request->getAttribute("queryData");
{{/internal.ze-ph.hasQueryData}}
{{/vendorExtensions}}
{{#bodyParam}}
{{^isPrimitiveType}}
        /** @var {{dataType}} $bodyData */
        $bodyData = $request->getAttribute("bodyData");
{{/isPrimitiveType}}
{{/bodyParam}}
        throw new PHException\HttpCode(500, "Not implemented");
    }
{{/operation}}
}
{{/operations}}
