RegisterResponse::setRegistrationData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 9.4285
1
<?php
2
/**
3
 *
4
 * @copyright (c) 2015, Paul Sohier
5
 * @copyright (c) 2014 Yubico AB
6
 * @license BSD-2-Clause
7
 *
8
 *
9
 * Orignal Copyright:
10
 * Copyright (c) 2014 Yubico AB
11
 * All rights reserved.
12
 *
13
 * Redistribution and use in source and binary forms, with or without
14
 * modification, are permitted provided that the following conditions are
15
 * met:
16
 *
17
 *   * Redistributions of source code must retain the above copyright
18
 *     notice, this list of conditions and the following disclaimer.
19
 *
20
 *   * Redistributions in binary form must reproduce the above
21
 *     copyright notice, this list of conditions and the following
22
 *     disclaimer in the documentation and/or other materials provided
23
 *     with the distribution.
24
 *
25
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
 */
37
38
namespace paul999\u2f;
39
use JsonSerializable;
40
41
/**
42
 * Class for building up an authentication request
43
 *
44
 * @package u2flib_server
45
 */
46
class RegisterResponse implements RegisterResponseInterface, JsonSerializable
47
{
48
    /**
49
     * @var string Registration data
50
     */
51
    private $registrationData;
52
53
    /** @var string client data */
54
    private $clientData;
55
56
    /** @var string errorCode from the browser */
57
    private $errorCode;
58
59
    /**
60
     * RegisterResponse constructor.
61
     * @param string $registrationData
62
     * @param string $clientData
63
     * @param int $errorCode
64
     */
65
    public function __construct($registrationData, $clientData, $errorCode = 0)
66
    {
67
        $this->setRegistrationData($registrationData);
68
        $this->setClientData($clientData);
69
        $this->setErrorCode($errorCode);
70
    }
71
72
    /**
73
     * @return string
74
     */
75
    public function getRegistrationData()
76
    {
77
        return $this->registrationData;
78
    }
79
80
    /**
81
     * @param string $registrationData
82
     * @return RegisterResponseInterface
83
     */
84
    public function setRegistrationData($registrationData)
85
    {
86
        $this->registrationData = $registrationData;
87
        return $this;
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    public function getClientData()
94
    {
95
        return $this->clientData;
96
    }
97
98
    /**
99
     * @param string $clientData
100
     * @return RegisterResponseInterface
101
     */
102
    public function setClientData($clientData)
103
    {
104
        $this->clientData = $clientData;
105
        return $this;
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getErrorCode()
112
    {
113
        return $this->errorCode;
114
    }
115
116
    /**
117
     * @param string $errorCode
118
     * @return RegisterResponseInterface
119
     */
120
    public function setErrorCode($errorCode)
121
    {
122
        $this->errorCode = $errorCode;
123
        return $this;
124
    }
125
126
    /**
127
     * Specify data which should be serialized to JSON
128
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
129
     * @return mixed data which can be serialized by <b>json_encode</b>,
130
     * which is a value of any type other than a resource.
131
     * @since 5.4.0
132
     */
133
    function jsonSerialize()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
134
    {
135
        return [
136
            'registrationData'  => $this->getRegistrationData(),
137
            'clientData'        => $this->getClientData(),
138
            'errorCode'         => $this->getErrorCode(),
139
        ];
140
    }
141
}