History::mergeInfo()   A
last analyzed

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 10
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 addStats(TransferStats $stats)
11
    {
12
        $this->mergeInfo($stats->getRequest(), ['info' => $stats->getHandlerStats()]);
13
    }
14
15
    public function mergeInfo(RequestInterface $request, array $info)
16
    {
17
        $info = array_merge([
18
            'response' => null,
19
            'error' => null,
20
            'info' => null,
21
        ], array_filter($this->contains($request) ? $this[$request] : []), array_filter($info));
22
23
        $this->attach($request, $info);
24
    }
25
}
26