Http::initiate()   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 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6667
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Ndrx\Profiler\Context;
4
5
use Ndrx\Profiler\Process;
6
7
/**
8
 * Created by PhpStorm.
9
 * User: arnaud
10
 * Date: 01/11/15
11
 * Time: 16:38
12
 */
13
class Http extends Context
14
{
15
    const HEADER_PROCESS = 'Process-Id';
16
17 4
    public function initiate()
18
    {
19 4
        parent::initiate();
20
21 4
        $processId = $this->request->headers->get(self::HEADER_PROCESS, null);
22
23 4
        $this->process = Process::build($processId);
24 4
        $this->process->setContext($this);
25 4
    }
26
27 2
    public function sendDebugIds()
28
    {
29 2
        if (!headers_sent()) {
30
            header(self::HEADER_PROCESS . ': ' . $this->process->getId());
31
        }
32 2
    }
33
}
34