Completed
Push — master ( 9ebe33 )
by Kaushik
28:24
created

GetTransactionDetailsResponse::set()   C

Complexity

Conditions 15
Paths 9

Size

Total Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 5.9166
c 0
b 0
f 0
cc 15
nc 9
nop 1

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace net\authorize\api\contract\v1;
4
5
/**
6
 * Class representing GetTransactionDetailsResponse
7
 */
8
class GetTransactionDetailsResponse extends ANetApiResponseType
9
{
10
11
    /**
12
     * @property \net\authorize\api\contract\v1\TransactionDetailsType $transaction
13
     */
14
    private $transaction = null;
15
16
    /**
17
     * @property string $clientId
18
     */
19
    private $clientId = null;
20
21
    /**
22
     * @property string $transrefId
23
     */
24
    private $transrefId = null;
25
26
    /**
27
     * Gets as transaction
28
     *
29
     * @return \net\authorize\api\contract\v1\TransactionDetailsType
30
     */
31
    public function getTransaction()
32
    {
33
        return $this->transaction;
34
    }
35
36
    /**
37
     * Sets a new transaction
38
     *
39
     * @param \net\authorize\api\contract\v1\TransactionDetailsType $transaction
40
     * @return self
41
     */
42
    public function setTransaction(\net\authorize\api\contract\v1\TransactionDetailsType $transaction)
43
    {
44
        $this->transaction = $transaction;
45
        return $this;
46
    }
47
48
    /**
49
     * Gets as clientId
50
     *
51
     * @return string
52
     */
53
    public function getClientId()
54
    {
55
        return $this->clientId;
56
    }
57
58
    /**
59
     * Sets a new clientId
60
     *
61
     * @param string $clientId
62
     * @return self
63
     */
64
    public function setClientId($clientId)
65
    {
66
        $this->clientId = $clientId;
67
        return $this;
68
    }
69
70
    /**
71
     * Gets as transrefId
72
     *
73
     * @return string
74
     */
75
    public function getTransrefId()
76
    {
77
        return $this->transrefId;
78
    }
79
80
    /**
81
     * Sets a new transrefId
82
     *
83
     * @param string $transrefId
84
     * @return self
85
     */
86
    public function setTransrefId($transrefId)
87
    {
88
        $this->transrefId = $transrefId;
89
        return $this;
90
    }
91
92
93
    // Json Set Code
94
    public function set($data)
95
    {
96
        if(is_array($data) || is_object($data)) {
97
			$mapper = \net\authorize\util\Mapper::Instance();
98
			foreach($data AS $key => $value) {
99
				$classDetails = $mapper->getClass(get_class() , $key);
100
	 
101
				if($classDetails !== NULL ) {
102
					if ($classDetails->isArray) {
103
						if ($classDetails->isCustomDefined) {
104
							foreach($value AS $keyChild => $valueChild) {
105
								$type = new $classDetails->className;
106
								$type->set($valueChild);
107
								$this->{'addTo' . $key}($type);
108
							}
109
						}
110
						else if ($classDetails->className === 'DateTime' || $classDetails->className === 'Date' ) {
111
							foreach($value AS $keyChild => $valueChild) {
112
								$type = new \DateTime($valueChild);
113
								$this->{'addTo' . $key}($type);
114
							}
115
						}
116
						else {
117
							foreach($value AS $keyChild => $valueChild) {
118
								$this->{'addTo' . $key}($valueChild);
119
							}
120
						}
121
					}
122
					else {
123
						if ($classDetails->isCustomDefined){
124
							$type = new $classDetails->className;
125
							$type->set($value);
126
							$this->{'set' . $key}($type);
127
						}
128
						else if ($classDetails->className === 'DateTime' || $classDetails->className === 'Date' ) {
129
							$type = new \DateTime($value);
130
							$this->{'set' . $key}($type);
131
						}
132
						else {
133
							$this->{'set' . $key}($value);
134
						}
135
					}
136
				}
137
			}
138
		}
139
    }
140
    
141
}
142
143