StateHandler   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 52
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setRequestId() 0 6 1
A getRequestId() 0 4 1
A clear() 0 4 1
A set() 0 4 1
A get() 0 4 1
1
<?php
2
3
/**
4
 * Copyright 2014 SURFnet bv
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 Surfnet\StepupRa\SamlStepupProviderBundle\Saml;
20
21
use Surfnet\StepupRa\GatewayBundle\Saml\Proxy\ProxyStateHandler;
22
use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag;
23
24
final class StateHandler
25
{
26
    /**
27
     * @var string
28
     */
29
    private $provider;
30
31
    /**
32
     * @var NamespacedAttributeBag
33
     */
34
    private $attributeBag;
35
36
    public function __construct(NamespacedAttributeBag $attributeBag, $provider)
37
    {
38
        $this->attributeBag = $attributeBag;
39
        $this->provider = $provider;
40
    }
41
42
    /**
43
     * @param string $originalRequestId
44
     * @return $this
45
     */
46
    public function setRequestId($originalRequestId)
47
    {
48
        $this->set('request_id', $originalRequestId);
49
50
        return $this;
51
    }
52
53
    /**
54
     * @return string|null
55
     */
56
    public function getRequestId()
57
    {
58
        return $this->get('request_id');
59
    }
60
61
    public function clear()
62
    {
63
        $this->attributeBag->remove($this->provider);
64
    }
65
66
    protected function set($key, $value)
67
    {
68
        $this->attributeBag->set($this->provider . '/' . $key, $value);
69
    }
70
71
    protected function get($key)
72
    {
73
        return $this->attributeBag->get($this->provider . '/' . $key);
74
    }
75
}
76