ExtraLazyRpcClient   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 29
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A invoke() 0 10 3
1
<?php
2
3
namespace ScayTrase\Api\Rpc\Decorators;
4
5
use ScayTrase\Api\Rpc\RpcClientInterface;
6
7
final class ExtraLazyRpcClient implements RpcClientInterface
8
{
9
    /** @var ExtraLazyResponseCollection */
10
    private $lazyCollection;
11
    /** @var LazyRpcClient */
12
    private $client;
13
14
    /**
15
     * ExtraLazyRpcClient constructor.
16
     *
17
     * @param RpcClientInterface $client
18
     */
19 4
    public function __construct(RpcClientInterface $client)
20
    {
21 4
        $this->client = new LazyRpcClient($client);
22 4
    }
23
24
    /** {@inheritdoc} */
25 4
    public function invoke($calls)
26
    {
27 4
        $collection = $this->client->invoke($calls);
28
29 4
        if (!$this->lazyCollection || $this->lazyCollection->getInnerCollection() !== $collection) {
30 4
            $this->lazyCollection = new ExtraLazyResponseCollection($collection);
0 ignored issues
show
Compatibility introduced by
$collection of type object<ScayTrase\Api\Rpc...nseCollectionInterface> is not a sub-type of object<ScayTrase\Api\Rpc...LazyResponseCollection>. It seems like you assume a concrete implementation of the interface ScayTrase\Api\Rpc\ResponseCollectionInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
31 4
        }
32
33 4
        return $this->lazyCollection;
34
    }
35
}
36