Completed
Push — feature/post-binding-without-c... ( c3fb1f )
by
unknown
02:20
created

ResponseHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isAdfsResponse() 0 4 1
A retrieveAdfsParameters() 0 8 1
1
<?php
2
3
/**
4
 * Copyright 2017 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\StepupGateway\SecondFactorOnlyBundle\Adfs;
20
21
use Psr\Log\LoggerInterface;
22
use Surfnet\StepupGateway\SecondFactorOnlyBundle\Adfs\ValueObject\Response as AdfsResponse;
23
24
/**
25
 * The Adfs helper service is used to transform Adfs response. Wrapping the SFO response in an ADFS friendly response
26
 * format:
27
 *
28
 * AuthMethod: <AuthMethod>
29
 * Context: <Conext>
30
 * RequestId: <RequestId>
31
 * Response: <The "Response" that was received from the SFO endpoint>
32
 *
33
 * @package Surfnet\StepupGateway\SecondFactorOnlyBundle\Service
34
 */
35
final class ResponseHelper
36
{
37
38
    /** @var LoggerInterface */
39
    private $logger;
40
41
    /** @var StateHandler */
42
    private $stateHandler;
43
44
    /**
45
     * ResponseHelper constructor.
46
     * @param StateHandler $stateHandler
47
     * @param LoggerInterface $logger
48
     */
49
    public function __construct(StateHandler $stateHandler, LoggerInterface $logger)
50
    {
51
        $this->stateHandler = $stateHandler;
52
        $this->logger = $logger;
53
    }
54
55
    /**
56
     * @param string $originalRequestId
57
     * @return bool
58
     */
59
    public function isAdfsResponse($originalRequestId)
60
    {
61
        return $this->stateHandler->hasMatchingRequestId($originalRequestId);
62
    }
63
64
    /**
65
     * @return AdfsResponse
66
     */
67
    public function retrieveAdfsParameters()
68
    {
69
        $authMethod = $this->stateHandler->getAuthMethod();
70
        $context = $this->stateHandler->getContext();
71
        $requestId = $this->stateHandler->getRequestId();
72
        $this->logger->notice(sprintf('Retrieving ADFS Response parameters for RequestId: "%s"', $requestId));
73
        return AdfsResponse::fromValues($authMethod, $context, $requestId);
0 ignored issues
show
Unused Code introduced by
The call to Response::fromValues() has too many arguments starting with $requestId.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
74
    }
75
}
76