Completed
Pull Request — master (#61)
by Tomas
02:14
created

CookieInputParam::getValue()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 4
nc 3
nop 0
crap 4
1
<?php
2
3
namespace Tomaj\NetteApi\Params;
4
5
class CookieInputParam extends InputParam
6
{
7
    protected $type = self::TYPE_COOKIE;
8
9 3
    public function getValue()
10
    {
11 3
        if (!filter_has_var(INPUT_COOKIE, $this->key) && isset($_COOKIE[$this->key])) {
12 3
            return $_COOKIE[$this->key];
13
        }
14 3
        $value = filter_input(INPUT_COOKIE, $this->key);
15 3
        return $value !== null ? $value : $this->default;
16
    }
17
}
18