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

CookieInputParam   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 13
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 8 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