Completed
Push — master ( 876946...08c288 )
by Bart
02:55
created

HeaderAttributesProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 42
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isEnabled() 0 4 1
A getAttributes() 0 8 2
1
<?php
2
3
namespace Kuleuven\AuthenticationBundle\Service;
4
5
use Symfony\Component\HttpFoundation\RequestStack;
6
7
class HeaderAttributesProvider implements AttributesInjectionProviderInterface
8
{
9
    /**
10
     * @var array
11
     */
12
    protected $requestStack;
13
14
    /**
15
     * @var bool
16
     */
17
    protected $enabled;
18
19
    /**
20
     * @param RequestStack $requestStack
21
     * @param bool         $enabled
22
     */
23
    public function __construct(RequestStack $requestStack, $enabled = false)
24
    {
25
        $this->requestStack = $requestStack;
0 ignored issues
show
Documentation Bug introduced by
It seems like $requestStack of type object<Symfony\Component...oundation\RequestStack> is incompatible with the declared type array of property $requestStack.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
26
        $this->enabled = $enabled;
27
    }
28
29
    /**
30
     * @return bool
31
     */
32
    public function isEnabled()
33
    {
34
        return $this->enabled;
35
    }
36
37
    /**
38
     * @return array
39
     */
40
    public function getAttributes()
41
    {
42
        $attributes = $this->requestStack->getCurrentRequest()->headers->all();
0 ignored issues
show
Bug introduced by
The method getCurrentRequest cannot be called on $this->requestStack (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
43
        array_walk($attributes, function (&$value) {
44
            $value = (is_array($value) ? implode(';', $value) : $value);
45
        });
46
        return $attributes;
47
    }
48
}
49