AccessControlServerResponse   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 2
Metric Value
wmc 4
c 5
b 0
f 2
lcom 1
cbo 1
dl 0
loc 57
ccs 17
cts 17
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 3 1
A getParameters() 0 3 1
A initializeByObject() 0 6 1
A __toString() 0 16 1
1
<?php
2
/*
3
 * Copyright 2015 Alexey Maslov <[email protected]>
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
namespace alxmsl\PaymentNinja\Response;
19
20
use alxmsl\PaymentNinja\ObjectInitializedInterface;
21
use stdClass;
22
23
/**
24
 * ACS data class
25
 * @author alxmsl
26
 */
27
final class AccessControlServerResponse implements ObjectInitializedInterface {
28
    /**
29
     * @var string URL where a user should be redirected with the secure3dParameters
30
     */
31
    private $url = '';
32
33
    /**
34
     * @var AccessControlServerParametersResponse parameters that should be passed to secure3dUrl​as-is using the
35
     *  HTTP POST method
36
     */
37
    private $parameters = null;
38
39
    /**
40
     * @return string URL where a user should be redirected with the secure3dParameters
41
     */
42 1
    public function getUrl() {
43 1
        return $this->url;
44
    }
45
46
    /**
47
     * @return AccessControlServerParametersResponse parameters that should be passed to secure3dUrl​as-is using the HTTP POST method
48
     */
49 1
    public function getParameters() {
50 1
        return $this->parameters;
51
    }
52
53
    /**
54
     * @inheritdoc
55
     * @return AccessControlServerResponse instance with ACS data
56
     */
57 1
    public static function initializeByObject(stdClass $Object) {
58 1
        $Result             = new AccessControlServerResponse();
59 1
        $Result->url        = (string) $Object->url;
60 1
        $Result->parameters = AccessControlServerParametersResponse::initializeByObject($Object->parameters);
61 1
        return $Result;
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67 1
    public function __toString() {
68
        $format = <<<'EOD'
69
        url:       %s
70
        parameters
71
            MD:    %s
72
            PaReq: %s
73
            Terms: %s
74
        query:     %s
75 1
EOD;
76 1
        return sprintf($format
77 1
            , $this->getUrl()
78 1
            , $this->getParameters()->getMerchantData()
79 1
            , $this->getParameters()->getPaymentAuthorizationRequest()
80 1
            , $this->getParameters()->getTermsUrl()
81 1
            , $this->getParameters()->getQuery());
82
    }
83
}
84