MessageContext   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 14
eloc 23
c 1
b 0
f 0
dl 0
loc 108
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getMessage() 0 3 1
A getBindingType() 0 3 1
A setBindingType() 0 5 1
A getSerializationContext() 0 3 1
A asAuthnRequest() 0 7 2
A asLogoutResponse() 0 7 2
A setMessage() 0 5 1
A getDeserializationContext() 0 3 1
A asResponse() 0 7 2
A asLogoutRequest() 0 7 2
1
<?php
2
3
/*
4
 * This file is part of the LightSAML-Core package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace LightSaml\Context\Profile;
13
14
use LightSaml\Model\Context\DeserializationContext;
15
use LightSaml\Model\Context\SerializationContext;
16
use LightSaml\Model\Protocol\AuthnRequest;
17
use LightSaml\Model\Protocol\LogoutRequest;
18
use LightSaml\Model\Protocol\LogoutResponse;
19
use LightSaml\Model\Protocol\Response;
20
use LightSaml\Model\Protocol\SamlMessage;
21
22
class MessageContext extends AbstractProfileContext
23
{
24
    /** @var SamlMessage */
25
    private $message;
26
27
    /** @var string */
28
    private $bindingType;
29
30
    /**
31
     * @return string
32
     */
33
    public function getBindingType()
34
    {
35
        return $this->bindingType;
36
    }
37
38
    /**
39
     * @param string $bindingType
40
     *
41
     * @return MessageContext
42
     */
43
    public function setBindingType($bindingType)
44
    {
45
        $this->bindingType = $bindingType;
46
47
        return $this;
48
    }
49
50
    /**
51
     * @return SamlMessage|null
52
     */
53
    public function getMessage()
54
    {
55
        return $this->message;
56
    }
57
58
    /**
59
     * @return MessageContext
60
     */
61
    public function setMessage(SamlMessage $message = null)
62
    {
63
        $this->message = $message;
64
65
        return $this;
66
    }
67
68
    /**
69
     * @return AuthnRequest|null
70
     */
71
    public function asAuthnRequest()
72
    {
73
        if ($this->message instanceof AuthnRequest) {
74
            return $this->message;
75
        }
76
77
        return null;
78
    }
79
80
    /**
81
     * @return LogoutRequest|null
82
     */
83
    public function asLogoutRequest()
84
    {
85
        if ($this->message instanceof LogoutRequest) {
86
            return $this->message;
87
        }
88
89
        return null;
90
    }
91
92
    /**
93
     * @return Response|null
94
     */
95
    public function asResponse()
96
    {
97
        if ($this->message instanceof Response) {
98
            return $this->message;
99
        }
100
101
        return null;
102
    }
103
104
    /**
105
     * @return LogoutResponse|null
106
     */
107
    public function asLogoutResponse()
108
    {
109
        if ($this->message instanceof LogoutResponse) {
110
            return $this->message;
111
        }
112
113
        return null;
114
    }
115
116
    /**
117
     * @return SerializationContext
118
     */
119
    public function getSerializationContext()
120
    {
121
        return $this->getSubContext(ProfileContexts::SERIALIZATION, SerializationContext::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getSubCont...lizationContext::class) also could return the type LightSaml\Context\ContextInterface which is incompatible with the documented return type LightSaml\Model\Context\SerializationContext.
Loading history...
122
    }
123
124
    /**
125
     * @return DeserializationContext
126
     */
127
    public function getDeserializationContext()
128
    {
129
        return $this->getSubContext(ProfileContexts::DESERIALIZATION, DeserializationContext::class);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getSubCont...lizationContext::class) also could return the type LightSaml\Context\ContextInterface which is incompatible with the documented return type LightSaml\Model\Context\DeserializationContext.
Loading history...
130
    }
131
}
132