ProfiledResponseCollection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 38
ccs 14
cts 14
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getResponse() 0 7 1
A getIterator() 0 7 2
1
<?php
2
3
namespace ScayTrase\Api\Rpc\Decorators;
4
5
use ScayTrase\Api\Rpc\ResponseCollectionInterface;
6
use ScayTrase\Api\Rpc\RpcRequestInterface;
7
8
final class ProfiledResponseCollection implements \IteratorAggregate, ResponseCollectionInterface
9
{
10
    /** @var  ResponseCollectionInterface */
11
    private $collection;
12
    /** @var  ProfiledClientStorage */
13
    private $profiler;
14
15
    /**
16
     * ProfiledResponseCollection constructor.
17
     *
18
     * @param ResponseCollectionInterface $collection
19
     * @param ProfiledClientStorage                 $profiler
20
     */
21 2
    public function __construct(ResponseCollectionInterface $collection, ProfiledClientStorage $profiler)
22
    {
23 2
        $this->collection = $collection;
24 2
        $this->profiler   = $profiler;
25 2
    }
26
27
28
    /** {@inheritdoc} */
29 1
    public function getResponse(RpcRequestInterface $request)
30
    {
31 1
        $response = $this->collection->getResponse($request);
32 1
        $this->profiler->registerResponse($response, $request);
33
34 1
        return $response;
35
    }
36
37
    /** {@inheritdoc} */
38 1
    public function getIterator()
39
    {
40 1
        foreach ($this->collection as $response) {
41 1
            $this->profiler->registerResponse($response);
42 1
            yield $response;
43 1
        }
44 1
    }
45
}
46