StateHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Copyright 2015 SURFnet B.V.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace OpenConext\ProfileBundle\Saml;
20
21
use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag;
22
23
class StateHandler
24
{
25
    /**
26
     * @var NamespacedAttributeBag
27
     */
28
    private $attributeBag;
29
30
    public function __construct(NamespacedAttributeBag $attributeBag)
31
    {
32
        $this->attributeBag = $attributeBag;
33
    }
34
35
    /**
36
     * @param string $originalRequestId
37
     * @return $this
38
     */
39
    public function setRequestId($originalRequestId)
40
    {
41
        $this->attributeBag->set('request_id', $originalRequestId);
42
43
        return $this;
44
    }
45
46
    /**
47
     * @return string|null
48
     */
49
    public function getRequestId()
50
    {
51
        return $this->attributeBag->get('request_id');
52
    }
53
54
    /**
55
     * @return bool
56
     */
57
    public function hasRequestId()
58
    {
59
        return $this->attributeBag->has('request_id');
60
    }
61
62
    /**
63
     * Removes the requestId from the session
64
     */
65
    public function clearRequestId()
66
    {
67
        $this->attributeBag->remove('request_id');
68
    }
69
70
    /**
71
     * @param string $uri
72
     */
73
    public function setCurrentRequestUri($uri)
74
    {
75
        $this->attributeBag->set('current_uri', $uri);
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function getCurrentRequestUri()
82
    {
83
        $uri = $this->attributeBag->get('current_uri');
84
        $this->attributeBag->remove('current_uri');
85
86
        return $uri;
87
    }
88
}
89