RequestAttributesContainer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 19
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\NavigationBundle\Bridge\Item;
6
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\RequestStack;
9
10
/**
11
 * Class RequestAttributesContainer.
12
 *
13
 * @author Ivan Barlog <[email protected]>
14
 */
15
class RequestAttributesContainer implements RequestAttributesContainerInterface
16
{
17
    /** @var RequestStack */
18
    private $requestStack;
19
20
    public function __construct(RequestStack $requestStack)
21
    {
22
        $this->requestStack = $requestStack;
23
    }
24
25
    public function get(string $name, string $default = ''): string
26
    {
27
        $request = $this->requestStack->getMainRequest();
28
29
        if (!$request) {
30
            return '';
31
        }
32
33
        return $request->get($name, $default);
34
    }
35
}
36