Completed
Push — master ( 19fab1...ec2cfc )
by ANTHONIUS
23s queued 11s
created

RemoteSession   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 29
ccs 7
cts 21
cp 0.3333
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A startSession() 0 24 4
1
<?php
2
3
/*
4
 * This file is part of the doyo/code-coverage project.
5
 *
6
 * (c) Anthonius Munthi <https://itstoni.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Doyo\Bridge\CodeCoverage\Session;
15
16
use Doyo\Bridge\CodeCoverage\TestCase;
17
18
class RemoteSession extends AbstractSession
19
{
20
    const HEADER_SESSION_KEY   = 'HTTP_DOYO_COVERAGE_SESSION';
21
    const HEADER_TEST_CASE_KEY = 'HTTP_DOYO_COVERAGE_TESTCASE';
22
23 2
    public static function startSession()
24
    {
25 2
        if (!isset($_SERVER[static::HEADER_SESSION_KEY])) {
26 1
            return false;
27
        }
28
29 1
        if(!isset($_SERVER[static::HEADER_TEST_CASE_KEY])){
30 1
            return false;
31
        }
32
33
        $sessionName = $_SERVER[static::HEADER_SESSION_KEY];
34
        $session = new static($sessionName);
35
        $testCaseName = $_SERVER[static::HEADER_TEST_CASE_KEY];
36
        $testCase = new TestCase($testCaseName);
37
38
        try{
39
            $session->setTestCase($testCase);
40
            $session->start();
41 1
            $session->save();
42 1
            return true;
43
        }catch (\Exception $e){
44
            $session->addException($e);
45
            $session->save();
46
            return false;
47
        }
48
    }
49
}
50