Passed
Push — master ( 00172d...2b6ede )
by Gabriel
03:22
created

request()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 5
c 1
b 0
f 1
nc 3
nop 2
dl 0
loc 9
ccs 0
cts 5
cp 0
crap 12
rs 10
1
<?php
2
3
if (!function_exists('request')) {
4
    /**
5
     * Get an instance of the current request or an input item from the request.
6
     *
7
     * @param array|string $key
8
     * @param mixed $default
9
     * @return Nip\Request|string|array
10
     */
11
    function request($key = null, $default = null)
12
    {
13
        $request = Nip\Utility\Container::get('request');
14
        if (is_null($key)) {
15
            return $request;
16
        }
17
        $value = $request->get($key);
18
19
        return $value ? $value : $default;
20
    }
21
}
22