GuzzleHttp   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 2
c 3
b 1
f 0
lcom 0
cbo 2
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php
2
namespace vipnytt\XRobotsTagParser\Adapters;
3
4
use Psr\Http\Message\ResponseInterface;
5
use vipnytt\XRobotsTagParser;
6
7
/**
8
 * Class GuzzleHttp
9
 *
10
 * Parse from an object witch implements the \Psr\Http\Message\ResponseInterface
11
 *
12
 * @package vipnytt\XRobotsTagParser\Adapters
13
 */
14
class GuzzleHttp extends XRobotsTagParser
15
{
16
    /**
17
     * Constructor
18
     *
19
     * @param \Psr\Http\Message\ResponseInterface $response
20
     * @param string $userAgent
21
     * @throws XRobotsTagParser\Exceptions\XRobotsTagParserException
22
     */
23
    public function __construct(ResponseInterface $response, $userAgent = '')
24
    {
25
        parent::__construct($userAgent);
26
        $headers = [];
27
        foreach ($response->getHeader(parent::HEADER_RULE_IDENTIFIER) as $name => $values) {
28
            $headers[] = $name . ': ' . implode(' ', $values) . "\r\n";
29
        }
30
        $this->parse($headers);
31
    }
32
}
33