Passed
Push — master ( 654348...8ec1ee )
by Dāvis
03:00
created

History::mergeInfo()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 1
nop 2
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Guzzle\GuzzleHttp\History;
4
5
use GuzzleHttp\TransferStats;
6
use Psr\Http\Message\RequestInterface;
7
8
class History extends \SplObjectStorage
9
{
10
    public function mergeInfo(RequestInterface $request, array $info)
11
    {
12
        $info = array_merge([
13
            'response' => null,
14
            'error' => null,
15
            'info' => null,
16
        ], array_filter($this->contains($request) ? $this[$request] : []), array_filter($info));
17
18
        $this->attach($request, $info);
19
    }
20
21
    public function addStats(TransferStats $stats)
22
    {
23
        $this->mergeInfo($stats->getRequest(), ['info' => $stats->getHandlerStats()]);
24
    }
25
}