<?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}}
class {{classname}} implements {{interfacesToImplement}}
{
{{#operation}}
    /**
{{#summary}}
     * {{summary}}
{{/summary}}
{{#description}}
     * {{description}}
{{/description}}
{{#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}}
     * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":{{dataType}}::class,"objectAttr":"{{paramName}}"})
{{/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}}
{{#returnType}}
     * @return {{returnType}}
{{/returnType}}
     */
    public function {{httpMethod}}(ServerRequestInterface $request)
    {
        //TODO implement method
{{#bodyParam}}
{{^isPrimitiveType}}
        /** @var {{dataType}} ${{paramName}} */
        ${{paramName}} = $request->getAttribute("{{paramName}}");
{{/isPrimitiveType}}
{{/bodyParam}}
        throw new PHException\HttpCode(500, "Not implemented");
    }
{{/operation}}
}
{{/operations}}
