Code Duplication    Length = 10-13 lines in 2 locations

src/Deferred.php 2 locations

@@ 41-50 (lines=10) @@
38
    {
39
        $deferred = new self($this->waitCallback);
40
41
        $this->onFulfilledCallbacks[] = function (ResponseInterface $response) use ($onFulfilled, $deferred) {
42
            try {
43
                if (null !== $onFulfilled) {
44
                    $response = $onFulfilled($response);
45
                }
46
                $deferred->resolve($response);
47
            } catch (Exception $exception) {
48
                $deferred->reject($exception);
49
            }
50
        };
51
52
        $this->onRejectedCallbacks[] = function (Exception $exception) use ($onRejected, $deferred) {
53
            try {
@@ 52-64 (lines=13) @@
49
            }
50
        };
51
52
        $this->onRejectedCallbacks[] = function (Exception $exception) use ($onRejected, $deferred) {
53
            try {
54
                if (null !== $onRejected) {
55
                    $response = $onRejected($exception);
56
                    $deferred->resolve($response);
57
58
                    return;
59
                }
60
                $deferred->reject($exception);
61
            } catch (Exception $newException) {
62
                $deferred->reject($newException);
63
            }
64
        };
65
66
        return $deferred;
67
    }