Code Duplication    Length = 11-13 lines in 2 locations

src/Generation/Builder/MethodBodyBuilder.php 2 locations

@@ 584-594 (lines=11) @@
581
        $this->methodBody->add('$request = $beforeSendEvent->getRequest();');
582
        $this->methodBody->add('try {');
583
584
        if ($this->callback !== null && $this->callbackOptional) {
585
            $this->methodBody->add('if (%s !== null) {', $this->callback);
586
            $this->methodBody->add('$response = $this->client->sendAsync($request, %s);', $this->callback);
587
            $this->methodBody->add('} else {');
588
            $this->methodBody->add('$response = $this->client->send($request);');
589
            $this->methodBody->add('}');
590
        } elseif ($this->callback !== null && !$this->callbackOptional) {
591
            $this->methodBody->add('$response = $this->client->sendAsync($request, %s);', $this->callback);
592
        } else {
593
            $this->methodBody->add('$response = $this->client->send($request);');
594
        }
595
596
        $this->methodBody->add('} catch (\Exception $exception) {');
597
        $this->methodBody->add('$apiExceptionEvent = new \Tebru\Retrofit\Event\ApiExceptionEvent($exception, $request);');
@@ 612-624 (lines=13) @@
609
     */
610
    private function createReturns()
611
    {
612
        if ($this->callback !== null && $this->callbackOptional) {
613
            $this->methodBody->add('if (%s !== null) {', $this->callback);
614
            $this->methodBody->add('$returnEvent = new \Tebru\Retrofit\Event\ReturnEvent(null);');
615
            $this->methodBody->add('$this->eventDispatcher->dispatch("retrofit.return", $returnEvent);');
616
            $this->methodBody->add('return $returnEvent->getReturn();');
617
            $this->methodBody->add('}');
618
        } elseif ($this->callback !== null && !$this->callbackOptional) {
619
            $this->methodBody->add('$returnEvent = new \Tebru\Retrofit\Event\ReturnEvent(null);');
620
            $this->methodBody->add('$this->eventDispatcher->dispatch("retrofit.return", $returnEvent);');
621
            $this->methodBody->add('return $returnEvent->getReturn();');
622
623
            return;
624
        }
625
626
        $matches = [];
627
        $returnType = $this->returnType;