context()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
if (! function_exists('context')) {
6
    /**
7
     * Get RPC request context.
8
     *
9
     * @param string $key
10
     * @param mixed $default
11
     * @return mixed
12
     */
13
    function context(string $key, $default = null)
14
    {
15 24
        $request = app('request');
16 24
        if (! $request instanceof Boomdraw\RpcCore\Request) {
17 3
            return $default;
18
        }
19
20 21
        return $request->context($key, $default);
21
    }
22
}
23