Completed
Pull Request — master (#61)
by Michal
02:15
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
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