PrerenderIoClient::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 4
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 1
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace MediaMonks\Crawler\Client;
4
5
use Symfony\Component\BrowserKit\History;
6
use Symfony\Component\BrowserKit\CookieJar;
7
8
class PrerenderIoClient extends PrerenderClient
9
{
10
    const URL = 'https://service.prerender.io/';
11
12
    const HEADER_TOKEN = 'HTTP_X-Prerender-Token';
13
    const HEADER_USER_AGENT = 'HTTP_USER_AGENT';
14
15
    const USER_AGENT = 'MediaMonks Crawler';
16
17
    /**
18
     * @var string
19
     */
20
    protected $token;
21
22
    /**
23
     * @param string $token Token from the prerender.io service
24
     * @param array $server The server parameters (equivalent of $_SERVER)
25
     * @param History $history A History instance to store the browser history
26
     * @param CookieJar $cookieJar A CookieJar instance to store the cookies
27
     */
28 2
    public function __construct($token, array $server = [], History $history = null, CookieJar $cookieJar = null)
29
    {
30 2
        $this->token = $token;
31
32 2
        $server[self::HEADER_TOKEN] = $token;
33 2
        $server[self::HEADER_USER_AGENT] = self::USER_AGENT;
34
35 2
        parent::__construct(self::URL, $server, $history, $cookieJar);
36 2
    }
37
38
}
39