Completed
Pull Request — master (#61)
by Michal
02:15
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
declare(strict_types=1);
4
5
namespace Tomaj\NetteApi\Params;
6
7
class CookieInputParam extends InputParam
8
{
9
    protected $type = self::TYPE_COOKIE;
10
11 3
    public function getValue()
12
    {
13 3
        if (!filter_has_var(INPUT_COOKIE, $this->key) && isset($_COOKIE[$this->key])) {
14 3
            return $_COOKIE[$this->key];
15
        }
16 3
        $value = filter_input(INPUT_COOKIE, $this->key);
17 3
        return $value !== null ? $value : $this->default;
18
    }
19
}
20