Completed
Push — feature/test ( fa6960 )
by Narcotic
09:36
created

HeaderFieldStrategy::apply()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * strategy for validating auth through the x-idp-username header
4
 */
5
6
namespace Graviton\SecurityBundle\Authentication\Strategies;
7
8
use Symfony\Component\HttpFoundation\Request;
9
10
/**
11
 * Class HeaderFieldStrategy
12
 *
13
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
14
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
15
 * @link     http://swisscom.ch
16
 */
17
class HeaderFieldStrategy extends AbstractHttpStrategy
18
{
19
    /** @var String */
20
    protected $field;
21
22
    /**
23
     * @param String $field field
24
     */
25
    public function __construct($field)
26
    {
27
        $this->field = $field;
28
    }
29
30
    /**
31
     * Applies the defined strategy on the provided request.
32
     * Value may contain a coma separated string values, we use first as identifier.
33
     *
34
     * @param Request $request request to handle
35
     *
36
     * @return string
37
     */
38 4
    public function apply(Request $request)
39
    {
40 4
        return $this->extractFieldInfo($request->headers, $this->field);
41
    }
42
}
43