Code Duplication    Length = 11-12 lines in 2 locations

Rpc/Request/RpcRequestCollection.php 1 location

@@ 26-36 (lines=11) @@
23
        return count($this->requests);
24
    }
25
26
    public function add(RpcRequestInterface $request)
27
    {
28
        if (!is_null($request)) {
29
            unset($this->requests[$request->getId()]);
30
            $this->requests[$request->getId()] = $request;
31
        } else {
32
            $key = array_search($request, $this->requests, true);
33
            unset($this->requests[$key]);
34
            $this->requests[] = $request;
35
        }
36
    }
37
38
    public function all()
39
    {

Rpc/Response/RpcResponseCollection.php 1 location

@@ 20-31 (lines=12) @@
17
        return count($this->responses);
18
    }
19
20
    public function add(RpcResponseInterface $response)
21
    {
22
        if (!is_null($response->getId())) {
23
            unset($this->responses[$response->getId()]);
24
            $this->responses[$response->getId()] = $response;
25
        } else {
26
            $key = array_search($response, $this->responses, true);
27
            unset($this->responses[$key]);
28
29
            $this->responses[] = $response;
30
        }
31
    }
32
33
    public function all()
34
    {