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

History   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addStats() 0 3 1
A mergeInfo() 0 9 2
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
}