Completed
Push — develop ( e149d8...a7cea2 )
by Lucas
08:25
created

CookieFieldStrategy::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 0
cts 3
cp 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * authentification strategy based on a username cookie
4
 */
5
6
namespace Graviton\SecurityBundle\Authentication\Strategies;
7
8
use Symfony\Component\HttpFoundation\Request;
9
10
/**
11
 * Class CookieFieldStrategy
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 CookieFieldStrategy extends AbstractHttpStrategy
18
{
19
    protected $field;
20
21
    /**
22
     * @param String $field field
23
     */
24
    public function __construct($field)
25
    {
26
        $this->field = $field;
27
    }
28
29
    /**
30
     * Applies the defined strategy on the provided request.
31
     *
32
     * @param Request $request request to handle
33
     *
34
     * @return string
35
     */
36 4
    public function apply(Request $request)
37
    {
38 4
        return $this->extractFieldInfo($request->cookies, $this->field);
39
    }
40
}
41