Code Duplication    Length = 13-15 lines in 2 locations

src/Generation/Handler/ResponseHandler.php 1 location

@@ 35-47 (lines=13) @@
32
        $context->body()->add('$request = $beforeSendEvent->getRequest();');
33
        $context->body()->add('try {');
34
35
        if (null !== $callback) {
36
            if ($context->annotations()->isCallbackOptional()) {
37
                $context->body()->add('if (%s !== null) {', $callback);
38
                $context->body()->add('$response = $this->client->sendAsync($request, %s);', $callback);
39
                $context->body()->add('} else {');
40
                $context->body()->add('$response = $this->client->send($request);');
41
                $context->body()->add('}');
42
            } else {
43
                $context->body()->add('$response = $this->client->sendAsync($request, %s);', $callback);
44
            }
45
        } else {
46
            $context->body()->add('$response = $this->client->send($request);');
47
        }
48
49
        $context->body()->add('} catch (\Exception $exception) {');
50
        $context->body()->add('$apiExceptionEvent = new \Tebru\Retrofit\Event\ApiExceptionEvent($exception, $request);');

src/Generation/Handler/ReturnHandler.php 1 location

@@ 31-45 (lines=15) @@
28
    {
29
        $callback = $context->annotations()->getCallback();
30
31
        if ($callback !== null) {
32
            if ($context->annotations()->isCallbackOptional()) {
33
                $context->body()->add('if (%s !== null) {', $callback);
34
                $context->body()->add('$returnEvent = new \Tebru\Retrofit\Event\ReturnEvent(null);');
35
                $context->body()->add('$this->eventDispatcher->dispatch("retrofit.return", $returnEvent);');
36
                $context->body()->add('return $returnEvent->getReturn();');
37
                $context->body()->add('}');
38
            } else {
39
                $context->body()->add('$returnEvent = new \Tebru\Retrofit\Event\ReturnEvent(null);');
40
                $context->body()->add('$this->eventDispatcher->dispatch("retrofit.return", $returnEvent);');
41
                $context->body()->add('return $returnEvent->getReturn();');
42
43
                return;
44
            }
45
        }
46
47
        $returnType = 'array';
48
        if (null !== $context->annotations()->getReturnType()) {